Sunday, January 22, 2012

Few Linux commnds that I am using these days for my PhD works


Convert Windows newline (CR+LF) characters to Linux newline (LF) characters:
$ perl -i -pe's/\r$//;' file.sh

Make a file executable:
$ chmod 700 file.sh

Latest top 40 files:
$ ls -lt | head -n 40

Unzip and Un-tar  file
$ tar –xvf file.tar.gz

Download multiple files in batch
$ wget -c "http://example.com/file[1-9].htm"

Replacing all the occurrences of foo on every line with bar
$ sed -e 's/foo/bar/g' myfile.txt

Count the number of files in a directory
$ ls | wc -l

Find lines beginning with >
$ grep -F ">" sort90


Merge files in ascending order

            $ ls -1 | xargs cat > ~/merged-output.out