Tuesday, January 24, 2012

make

sometime 'make' can give you error like
"make[1]: Nothing to be done for `all'"
In such case try first " make clean "

make clean
make

Friday, May 27, 2011

run a command/script on list of files

you have a program/script for something which takes input as file name and gives you output e.g.
python abc.py data_10.dat

And now you have a list of data files and you want to run this script on all the files in list. One way is to do so is open the list file in Python and make a for loop for the file list. You may have to change many things in script. So here is easy solution.

for file in `cat list`; do python abc.py $file; done


and you are done :)

Wednesday, June 9, 2010

For HPC

To view current job status
qstat

To view different queue status in HPC
qstat -g c

To delete a job
qdel jobID

To delete all jobs of a user
qdel -u USERNAME

Sunday, June 6, 2010

linux command

to count file number in a directory
ls -l your/directory/ | wc -l

to count number in a directory
wc -l your_file.txt


directory size in MB
du -sh your/directory/


file size in MB
ls -l | awk '{printf "%s %i %s %s %.3fMB %s %i %s %s\n", $1,$2,$3,$4,$5/1024000,$6,$7,$8,$9}'

Cut (split) a single file in multiple files
perl -n -e '/^pattern/ and open FH, ">output_".$n++; print FH;' input_file
pattern is the text on the basis of which files will be spliced.
other possible methods are -
awk '/^pattern/{close("file"f);f++}{print $0 > "file"f}' input.txt
csplit -k input.txt '/^pattern/' '{99}'


Display file lines
head -15 file_name
It will show first 15 lines of file. By default 'head' will show the first 10 lines

tail -15 file_name
It will show last 15 lines of file. By default 'tail' will show the last 10 lines