tr

transliterate: replaces chars in one list with corresponding chars in another list. Pure filter (standard input only).
/usr/ucb/tr BSD tr has this easier syntax.

Ex. myfile Newline at end. tr sees newlines, i.e. is not "line-oriented" like grep and sed.
Computo, ergo sum.

$ tr a-z A-Z <myfile # capitalize all letters
COMPUTO, ERGO SUM.

$ tr aeiou X <myfile # change lowercase vowels to X
CXmpXtX, XrgX sXm.

-d option: one list of chars to delete
$ tr -d aeiou <myfile # delete lowercase vowels
Cmpt, rg sm.

$ tr -d \\r <dosfile
# delete the carriage return \r chars of a DOS file. od -c to see

-c option: use opposite of first list
$ tr -c aeiou '*' <myfile # change every char except lowercase vowel to *
*o**u*o**e**o**u***$
(newline changed too)

-s option: compress (squeeze) runs of same converted char into one char
$ tr -cs aeiou '*' <myfile
*o*u*o*e*o*u*$

tr -dc a-zA-Z <myfile #delete non-letters

Ex. Convert input to one word per line:
$ tr -cs A-Za-z '\012' <myfile # non-letters convert to newline, compress. Octal 12=newline or use \n
Computo
ergo
sum
$
tr '()' '{}'       # change parens to braces

tr ab ba           # swap a and b

tr \'\" \"\'       # swap single and double quotes

tr -cs 0-9 ''      #all digits only, onto one line
********************************************************

sort

Options:

-r      reverse order (i.e. descending)
-f          fold lowercase into uppercase letters
-u      eliminate duplicate lines
-d      letters, digits, spaces only (ie. ignore punctuation chars)
-n      numerically  else 10 < 9
-k N     sort from the Nth field
+i       sort from the i+1th field
-i   sort to i+1th field
+i.j sort on i+1th field starting at j+1th position of that field
-tc      change field separator to c

-b  ignore leading blanks (fields start at first leading blank)
-o  output file (can be input file)

$ sort -r -n -t: +2 /etc/passwd
# sort passwd file in reverse order, numerically by UID

$ sort -n +1 -2
#sort numerically on second field
$ sort -n +4 -5 +1 -2
#sort fourth field primary sort key, second field secondary key
$ sort -o combo a b c #merge previously sorted a b c files into combo file

**********************************************************
cut
extract columns or fields from a file. Vertical slices.

-ccolumn-list
$ cut -c1-3,5-10 myfile
# columns 1,2,3,5,6,7,8,9,10 to output

-ffield-list default field separator is Tab
$ cut -f2,5 myfile
# fields 2 and 5 output

-dc change field separator to c
$ cut -f2 "-d " myfile
# space as field separator, output 2nd field

$ cut -f5 -d: /etc/passwd
# name field of password file

**************************************************************
paste
files together side by side
(cat concatenates files)