gzip / bzip2 can compress individual files. To compress entire folder structure ‘tar’ command comes to our rescue. Compress to .gz  tar -zcf </path/output.gz>  /sourcefolder/path Compress to .bz2 tar -jcf </path/output.bz2> /sourcefolder/path tar options : -z : gzip -c : compress -f : filename -j : bzip2  … (0 comment)

Simple script to covert  regular  date time to unix epoch time format  (UTC) $dat=’01/02/2015′ #If date is passed without time then its assumed as midnight  00:00:00 for that day. $sepoch=$(date “+%s” -d “$dat”) $echo $sepoch will return 1420156800 #If you need for specific datetime, then add time (24 h format) $sepoch=$(date “+%s” -d “$dat  13:15:00”)… (0 comment)

Easy way to split date into  Day, Month, Year  in Linux.  This code was tested using Bash shell. $dat=’13/2/2015′ sday=$(date -d “$dat” ‘+%d’) smonth=$(date -d “$dat” ‘+%m’) sfourdigityear=$(date -d “$dat” ‘+%Y’) stwodigityear=$(date -d “$dat” ‘+%y’) echo $sday  will display   02 echo $smonth  will display   13 echo $sfourdigityear  will display   2015 echo $stwodigityear  will display… (0 comment)

If is just filename  (samplefile.txt) then follow these steps. $ fullname=”samplefile.txt” $ extension=”${fullname##*.}” $ filename=”${fullname%.*}” $ echo $extension result : txt $ echo $filename result : samplefile   If filename is part of path  (/usr/gchan/samplefile.txt) $ fullname =”/usr/gchan/samplefile.txt” # Remove the path and get only  “samplefile.txt” $ fullname=”${fullname##*/}”   $ echo $fullname result : samplefile.txt #… (0 comment)

Recently I have been noticing some weird special characters on my PuTTy screen.  There was no pattern to it. It will appear all of a sudden. Its so annoying when you are working on a script. ex: ^[[28~ Reason : To keep my windows active from locking, I had installed an application called ‘caffeine’ .  Caffeine… (0 comment)