Micro and Nano Mechanics Group
(Difference between revisions)
 

Latest revision as of 10:38, 17 April 2013

Contents

[edit] List of Common Commands

( in alphabetical order )

[edit] cat

cat to look, modify or combine a file

 cat runs/mo-example/A.log | tail -n +10 | head -n 20-10+1 > B.log

[edit] cd

cd to change your current directory Go to your home directory

 cd ~

Go to a specified directory, e.g.

 cd /tmp

You can use

 cd -

to toggle between two directories with no effort at all.

[edit] cmp

cmp performs byte-by-byte comparison between two files.

[edit] diff

diff -b can be used to compare two files when the tabbing and whitespace has been changed in a code (tabbing, blank lines, spaces, etc). Regular diff will state that 'a=b' is different than 'a = b'.

[edit] dos2unix

dos2unix can be used to remove the ^M characters at the end of lines of your text files. However, if ^M appears not at the end of lines, this command will not remove it. You can use grep [ctrl-v][ctrl-m] yourfile to see whether yourfile still contains this character. You can then use vi yourfile and type command /[ctrl-v][ctrl-m] to search this character and then delete it.

[edit] find

find to search for files in a directory hierarchy

 find ./ -name param.inc

[edit] fmt

fmt makes multi-line text outputs fit nicely in a page by inserting and removing new lines.

[edit] grep

grep to show lines matching a pattern from files

 grep EPOT runs/mo-example/A.log
 grep -3 Stress runs/mo-example/A.log
 grep -w mea Fortran/MEAM-Baskes/meam/*

[edit] head

head to show the first several lines of the file

 head -n 20 runs/mo-example/A.log  #view the first 20 lines
 head -n -20 runs/mo-example/A.log #ignore the last 20 lines

[edit] nm

nm to list symbols from object files

 nm Fortran/MEAM-Baskes/meam/linux/forces.o | grep phiid

[edit] sed

sed to read the input file line by line

 sed  -n -e 10p -e 20p runs/mo-example/A.log #view the 10th and the 20th lines
 sed  -n 10, 20p runs/mo-example/A.log #view the lines from 10th to 20th   

[edit] sum

sum performs checksum of file. If the checksum is unchanged, the content of the file is likely unchanged.

[edit] tail

tail to show the last several lines of the file

 tail -n 10 runs/mo-example/A.log # view the last 10 lines of the file
 tail -n +10 runs/mo-example/A.log #ignore the first 10-1 lines of the file
 tail -f runs/mo-example/A.log # view growing log file in real time
 tail -c10 runs/mo-example/A.log #view the last 10 bytes of the file

[edit] tar

tar the tar archiving utility

 tar -zxvf MD++.tar.gz
 tar -jxvf highlight-2.6.5.tar.bz2
 tar -cvzf foo.tar.gz foo
 tar -cvjf foo.tar.bz2 foo
 tar cvf MD++.tar MD++ --exclude MD++/runs --exclude MD++/scripts/work --exclude MD++/cookies --exclude ".svn"
$ tar --create --tape-length=2097152 --file=results-NACL2-1.tar results-NACL2
Prepare volume #2 for `results-NACL2-1.tar' and hit return: n results-NACL2-2.tar
Prepare volume #2 for `results-NACL2-2.tar' and hit return: 
Prepare volume #3 for `results-NACL2-2.tar' and hit return: n results-NACL2-3.tar
Prepare volume #3 for `results-NACL2-3.tar' and hit return: 
Prepare volume #4 for `results-NACL2-3.tar' and hit return: n results-NACL2-4.tar
Prepare volume #4 for `results-NACL2-4.tar' and hit return:

[edit] yum

yum (Yellowdog Updater Modified) update program

 yum search gcc
 yum list installed | grep python-numeric
 yum remove python-numeric.i386
 yum install python-numeric.i386
 yum check-update gcc.i386
 yum update gcc.i386
 yum info gcc.i386


[edit] Other Resources

List of Unix Programs