cat ideas.txt egrep "C" ideas.txt egrep "C\>" ideas.txt egrep "\" ideas.txt less hamlet.txt egrep "act" hamlet.txt egrep "Act" hamlet.txt egrep "\" hamlet.txt egrep -i "^Act\>" hamlet.txt egrep -i "scene" hamlet.txt egrep -i "^scene" hamlet.txt egrep -i "^Act\>|^Scene" hamlet.txt cat chat.txt egrep "\^" chat.txt egrep "\^\^" chat.txt egrep "\^_\^" chat.txt egrep "\^.*\^" chat.txt egrep "(\^\^|\^_\^)" chat.txt egrep "\^_?\^" chat.txt cat 143.txt egrep "[ABCDF]" 143.txt egrep "[A-DF][+\-]?" 143.txt egrep "[A-DF][+\-]?$" 143.txt cat contact.html egrep "[0-9]" contact.html egrep "\([0-9]" contact.html egrep "\([0-9]{3}" contact.html egrep "\([0-9]{3}\)" contact.html egrep "\([0-9]{3}\) [0-9]{3}" contact.html egrep "\([0-9]{3}\) [0-9]{3}-[0-9]" contact.html egrep "[0-9]{3}-[0-9]{4}" contact.html # Replace occurences of Jones with Anderson # Replace Jones every time it occurs on a line. sed -r "s/Jones/Anderson/g" names.txt # Only replace the first occurence of Jones on a line. sed -r "s/Jones/Anderson/" names.txt # Swap order of first and last names: sed -r "s/([A-Za-z]+), ([A-Za-z]+)/\2 \1/g" names.txt # Demonstrate parenthesis inside of parenthesis: sed -r "s/(([A-Za-z]+), ([A-Za-z]+))/Last: \3 First: \2 Original: \1/g" names.txt # Match lines with the same name separated by a comma and space: name, name egrep "([A-Za-z]+), \1" names.txt # Put a dot where the dash is currently. sed -r "s/([0-9]{3})-([0-9]{4})/\1\.\2/g" contact.html # Send the output to a file (can't use the same file name as source and dest) sed -r "s/([0-9]{3})-([0-9]{4})/\1\.\2/g" contact.html > contact2.html