Wednesday, August 27, 2008

Unix Commands

Command to print file path

To print the file name prefix with path, use this command

find `pwd` -type f

Command to search for text in specific files

find . -type f -name "MSG0710*.xml" -exec grep "Email Confirmation" '{}' \; -print

Command to find files and delete it with confirmation

$ find $HOME/. -name *.txt -ok rm {} \;

Thursday, July 26, 2007

Unix Commands

Command option to print line number with grep

grep -n pattern filename

With the line number use tail + file | more to see the content of the file from that line onwards.

Command option to print the number of occurences

grep -c pattern filename

or

grep pattern filename | wc -l

To see the last occurrences

tail -1000 filename | grep pattern

Thursday, July 05, 2007

Unix Commands

  1. To see the disk usage use df -ks .
  2. To see the disk usage in gb use df -gs .
  3. To see which ports are in use or see available ports use these commands
    netstat -an find /i "listening"