This is for quick copy only, where you don't want to setup any ftp or scp server
and have the machines in same network
## say we have two hosts: alpha & beta
## need to copy: file-big.tgz
## linux util: nc
on host: alpha
$ cat file-big.tgz | nc -v -l 3334
now get the file on host:beta
$ nc -v alpha 3334 > file-from-alpha-file-big.tgz
voila, we have the file on host beta...
Thursday, July 16, 2015
Tuesday, June 2, 2015
milliseconds to date
Most of the java apps use milliseconds, here is bash date for getting the date for the same
## Current system date
## Epoch system date
## Milliseconds for the date
## Last 3 digits are for millisecs, so put decimal point and you get the get
## or strip of Last 3 digits
## Current system date
$ date
Tue Jun 2 08:07:57 UTC 2015
$ date +"%s"
1433232485
$ date +"%s%3N"
1433232489392
$ date -d @"1433232489.392"
Tue Jun 2 08:08:09 UTC 2015
$ date -d @"1433232489"
Tue Jun 2 08:08:09 UTC 2015
Thursday, March 5, 2015
script for reading file or stream
I often wanted to pass the file to a pipeline some command, and also if the file is parameter to command it should accept
Voila!!
here is 'stream.sh'
Voila!!
here is 'stream.sh'
#!/bin/bash
file=${1:--}
cat $file
Usage and output
$ ./stream.sh underSTANDING.txt
If you understand, say "understand".
If you don't understand, say "don't understand".
But if you understand and say "don't understand".
How do I understand that you understand? Understand!
$ cat underSTANDING.txt | ./stream.sh
If you understand, say "understand".
If you don't understand, say "don't understand".
But if you understand and say "don't understand".
How do I understand that you understand? Understand!
$ ./stream.sh < underSTANDING.txt
If you understand, say "understand".
If you don't understand, say "don't understand".
But if you understand and say "don't understand".
How do I understand that you understand? Understand!
bytes to gb/tb conversion
Often had to go to websites to do the bytes to KB.. TB.. GB conversions
here is the quick script for handy use
Usage and output
here is the quick script for handy use
#!/bin/bash# Give numeric value, which is in bytes# will show all possible conversionscall_bc() {n1=$1n2=$2echo "scale=4; $n1/($n2)" |bc}nm=$1pw=$2pn=""k_ilo=1024;m_ega=$k_ilo*$k_ilo;g_iga=$m_ega*$k_ilo;t_era=$g_iga*$k_ilo;p_eta=$t_era*$k_ilo;[ -z "$nm" ] && exitecho "B: "$nmfor i in K M G T P; docase $i inK)pn=$k_ilo;;M) let pn=$m_ega;;G) let pn=$g_iga;;T) let pn=$t_era;;P) let pn=$p_eta;;esacecho -n "$i: "; call_bc $nm $pndone
Usage and output
$ ./convert.sh 74274576B: 74274576K: 72533.7656M: 70.8337G: .0691T: 0P: 0
Subscribe to:
Posts (Atom)