Regular Expression: Lesson #2

C. is continue to be interested in regular expression. The most fun one seems to be the way to find palindromes

find palindromes with 5 letters


words=/usr/share/dict/words
cat $words | grep '(.)(.)(.)\2\1'

Find any word starting with C, replace with K


cat tck | sed 's/^C/K/'

Find any word ending in Y, replace with I


cat tck | sed 's/Y$/I/

find words with either 1-3 or 5-7


cat no.file | grep '[1-3]|5-7]'

find words with any letter between m and p


cat /usr/share/dict/words | grep '[m-p]'