A web development/programming blog providing info, tips, and tricks on programming languages, scripting, Linux, MySQL and more
sed Cheat Sheet
- s/regexp/replacement
- If the search is successful, replace regexp with replacement.
- sed ’s/oldword/newword/g’
- Substitute newword for oldword. The g makes the substitution global otherwise only the first occurrence of oldword would be matched.
- sed ’s/word/d’
- Delete the entire line that contains word
- sed ’s/word//’
- Delete just the word word
- sed -n ‘10,20p;20q’
- Print lines 10-20

