1. # text processing:
    1. # convert characters from lower to upper case:
       fortune | tr [:upper:] [:lower:] 
      
    2. # finding out how many times a particular item, in this case a dot, occurs on a text line
       for a in `cat /tmp/file.txt`; do
        nof=$[`echo $a|sed s/'\.'/'\n'/g|wc -l` -1]
        echo  a . occurs $nof times in $a
       done
      
    3. # unescaping escaped text/html/javascript/... found in a file $LOGFILE:
       cat $LOGFILE|sed s/+/' '/g|sed s/%0D%0A/" -- "/g|sed s/%20/" "/g|sed s/%21/'!'/g|\
      sed s/%22/'"'/g|sed s/%23/'\#'/g|sed s/%24/"$"/g|sed s/%25/"%"/g|sed s/%26/"\&"/g|sed s/%27/"'"/g|\
      sed s/%28/'('/g|sed s/%29/')'/g|sed s/%2A/'*'/g|sed s/%2B/'+'/g|sed s/%2C/','/g|sed s/%2D/'-'/g|\
      sed s/%2E/'.'/g|sed s/%2F/'\/'/g|sed s/%3A/':'/g|sed s/%3B/';'/g|sed s/%3C/'<'/g|sed s/%3D/'='/g|\
      sed s/%3E/'>'/g|sed s/%3F/'?'/g|sed s/%40/'@'/g|sed s/%5B/'['/g|sed s/%5C/'\\'/g|sed s/%5D/']'/g|\
      sed s/%5E/'^'/g|sed s/%5F/'_'/g|sed s/%60/'`'/g|sed s/%7B/'{'/g|sed s/%7C/'|'/g|sed s/%7D/'}'/g|\
      sed s/%7E/'~'/g|sed s/%D3/'<'/g 
      
    4. # a very nice overview of commonly used text processing commands can be found at http://www.tldp.org/LDP/abs/html/textproc.html
    5. # remove all blank lines from a file:
       grep -v '^$' input.txt > output.txt 
      
    6. # count the number of newlines, words and bytes in a text file:
       wc input.txt 
      
    7. # reverse all the lines in a file:
       rev file.txt 
      
  2. # searching for specific patterns using grep and regular expressions (mostly copied from http://www.robelle.com/library/smugbook/regexpr.html):
    1. # the theory:
       ^ (Caret)        =    match expression at the start of a line, as in ^A.
       $ (Question)     =    match expression at the end of a line, as in A$.
       \ (Back Slash)   =    turn off the special meaning of the next character, as in \^.
       [ ] (Brackets)   =    match any one of the enclosed characters, as in [aeiou].
                             Use Hyphen "-" for a range, as in [0-9].
       [^ ]             =    match any one character except those enclosed in [ ], as in [^0-9].
       . (Period)       =    match a single character of any value, except end of line.
       * (Asterisk)     =    match zero or more of the preceding character or expression.
       \{x,y\}          =    match x to y occurrences of the preceding.
       \{x\}            =    match exactly x occurrences of the preceding.
       \{x,\}           =    match x or more occurrences of the preceding. 
      
    2. # examples:
       cat -v -e -t dump                           # show non-printing characters too
       grep BOB tmpfile                        # search 'tmpfile' for 'BOB' anywhere in a line
       grep -i -w blkptr *                     # case insensitive search all files in the current directory for the word blkptr
       grep run[- ]time *.txt                  # find 'run time' or 'run-time' in all txt files
       grep smug files                         # search files for lines with 'smug'
       grep '^smug' files                      # 'smug' at the start of a line
       grep 'smug$' files                      # 'smug' at the end of a line
       grep '^smug$' files                     # lines containing only 'smug'
       grep '\^s' files                        # lines starting with '^s', "\" escapes the ^
       grep '[Ss]mug' files                    # search for 'Smug' or 'smug'
       grep 'B[oO][bB]' files                  # search for BOB, Bob, BOb or BoB 
       grep '^$' files                         # search for blank lines
       grep '[0-9][0-9]' file                  # search for pairs of numeric digits
       grep '^From: ' /var/spool/mail/$USER    # list your mail
       grep '[a-zA-Z]'                         # any line with at least one letter
       grep '[^a-zA-Z0-9]                      # anything not a letter or number
       grep '[0-9]\{3\}-[0-9]\{4\}'            # 999-9999, like phone numbers
       grep '^.$'                              # lines with exactly one character
       grep '"smug"'                           # 'smug' within double quotes
       grep '"*smug"*'                         # 'smug', with or without quotes
       grep '^\.'                              # any line that starts with a Period "."
       grep '^\.[a-z][a-z]'                    # line start with "." and 2 lc letters 
      
  3. # file processing:
    1. # count the number of times a particular character (in the example a comma) occurs in some file:
       cat file.txt | tr -c -d ',' | wc -c 
      
    2. # character set translator -- translates character sets from one encoding to another (utf-8, ascii, iso 8859-[123456789], unicode, msdos,...):
       tcs 
      
    3. # make a hexdump or do the reverse:
       xxd file > file.hex
       xxd -r file.hex > file.bis 
      
    4. # dump a file byte per byte using octet, decimal, hex or binary notation:
       od -j 2 -t x1 file > file.hex 
      
    5. # replace all spaces in all relevant file names by underscores:
       find . -name \*' '\* -exec rename s/' '/_/g "{}" \; 
      
    6. # strip the path from a filename, or the last part of an absolute path:
       basename extendedFilename; dirname extendedFilename 
      
    7. # find all files that are between 100 and 50 days old:
       find . -mtime +50 -mtime -100 -daystart 
      
  4. # process processing:
    1. # redirect stderr to stdout:
       buggyProg 2>&1 
      
    2. # redirect stdout to stderr:
       buggyProg 1>&2 
      
    3. # redirect both stderr and stdout to a file:
       buggyProg &> file