Text-related commands

grep pattern textfile
Print lines from the file textfile that contain pattern

grep -v pattern textfile
Print lines from the file textfile that do not contain pattern

cut -d: -f1,4 filename
For each line in the text file filename, split the line into sections using the character specified by -d as the delimiter (in this case, :) and print out the sections specified by -f (in this case, the first and fourth sections). awk is a more powerful utility that can do similar tasks and more.

sed 's/pattern1/pattern2/g' filename
Replace (substitute) each occurrence of pattern1 with pattern2 in the text file filename





Matt Disney 2005-09-14