Useful Command Line Reference

Whenever I write a shell script I find myself trying to construct command line arguements to achieve what I want. Then I google the problem I'm going to solve and find better ways to do it. By the next time I need to solve a similar problem I forget what I've done... hence this post.

To list all files without extension:

======================================

ls -R | grep -v "\." To sum the first column of values: ====================================== awk '{tot=tot+$1} END {print tot}'

 

Today's name abbreviated:

======================================

date +%a

Send an email message:

======================================

mail -s "subject line" blah@blah.com < /path/to/file

Traverse syslog directory, find all files with no extension, find out size

======================================

#Get Kilobytes for Today's files into <date>daily with full path

find -f /data/ | grep -v "\." | grep -e [Wed]/[0-9][0-9]$ | \ xargs du -k > /home/staff/akonkol/scripts/$filename

  • "find -f" will list the all the files/directorie's full path
  • "grep -v "\." will find everything that is not a directory
  • "grep -e" will find all paths that end with today's abbreviation slash num num
  • "xargs du -k" will perform a "du -k" on every path that is piped in.
Tagged as cli , command line linux , unix
Written by Andrew Konkol on November 16th, 2008

0 Comments

Log in with Twitter, Google, Facebook, LinkedIn to leave a comment.