2014-11-18

Shell Script to get last month date


Source URL: http://www.unix.com/unix-for-dummies-questions-and-answers/99281-how-get-previous-month-using-date.html




















j=`date +"%m"`; echo $j; i=`expr $j - 1`; echo $i;


Output:
11
10





enhance:

j=`date +"%m"`; echo $j; i=`expr $j - 1`; echo $i; echo `date +"%Y$i%d_%p%H%M"`

Output:
11
10
20141018_AM0340





How to: check linux(CentOS) version


Shared by Dhany



cat /ect/*release*


gzip status progress shell script with Pipe Viewer


Pipe Viewer Source URL: http://www.ivarch.com/programs/pv.shtml

If you don't have Pipe Viewer Current version: 1.5.7:
CentOS / RHEL:Set up my YUM repository or use RepoForge, then do "yum install pv".








Source URL 1 of 2:
http://stackoverflow.com/questions/238073/how-to-add-a-progress-bar-to-a-shell-script

$ bar file1 | wc -l 
$ pv file1 | wc -l

$ tail -n 100 file1 | bar | wc -l
$ tail -n 100 file1 | pv | wc -l

$ copy <(bar file1) file2
$ copy <(pv file1) file2

bar --in-file /dev/rmt/1cbn --out-file \
     tape-restore.tar --size 2.4g --buffer-size 64k









































Source URL 2 of 2:
http://stackoverflow.com/questions/19598797/is-there-any-way-to-show-progress-on-a-gunzip-database-sql-gz-mysql-pr


$ pv database1.sql.gz | gunzip | mysql -u root -p database1

$ pv database1.sql.gz | gunzip | mysql -uroot -p database1
  593MiB 1:00:33 [ 225kiB/s] [====================>              ] 58% ETA 0:42:25

mysqldump -uroot -p database1 | pv | gzip -9 > database1.sql.gz





Create recursively folders using shell script

Source URL: http://stackoverflow.com/questions/8274920/is-it-possible-create-recursively-folders-using-shell-script


mkdir -p folder1/folder2/folder3








Google Referrals