Archive for the ‘bash’ Category

a bash script launched remotely via ssh does not load the environment, if this is an issue it is necessary to specify –login when calling bash: ssh user@remoteserver.com ‘bash –login life_om/cronodproc’ | mail your@email.com -s cronodproc


folders are not counted find . -type f | wc -l


using gnu find

03Oct06

list all the directories excluding “.”: find . -maxdepth 1 -type d -not -name “.*” find some string in all files matching a pattern in the subfolders (with grep -r you cannot specify the type of file) find . -name ‘*.py’ -exec grep -i pdb ‘{}’ \;


great guide with many examples: http://tille.xalasys.com/training/bash/


tar quickref

25Sep06

compress: tar cvzf foo.tgz *.cc *.h check inside: tar tzf foo.tgz | grep file.txt extract: tar xvzf foo.tgz extract 1 file only: tar xvzf foo.tgz path/to/file.txt


Very useful summary of many linux command line processing tools (great perl onliners) http://grad.physics.sunysb.edu/~leckey/personal/forget/


awk made easy

22Sep06

awk ‘/REGEX/ {print NR “\t” $9 “\t” $4″_”$5 ;}’ file.txt supports extended REGEX like perl ( e.g. [:blank:] Space or tab characters ) NR is line number NF Number of fields $n is the column to be printed, $0 is the whole row if it only necessary to print columns of a file it is [...]



Follow

Get every new post delivered to your Inbox.