Edits streams by applying commonly used modifications.
cat some-file.txt | sed 's/me/you/g'
Replaces all occurrences of “me” with “you”.
echo "about\nabuse\namount" | sed 's/a\(\w*\?\)\w/\1/g'
bou bus moun
\1refers to the first captured group.
Transform to lowercase
echo "HELLO THERE\nHI THERE\nGOODBYE" | sed 's/H\w*/\L&/g'
hello There hi There GOODBYE
- Transforms words beginning with “H” to lowercase.
&is the place holder for “entire match”.
Transform to uppercase
cat some-file.txt | sed 's/.*/\U&/g'
Transforms all letters into uppercase.
About Living in the Shell
Obsessed with doing things in the shell, I’ve decided to share my daily struggles on living in the shell as terse but informative posts.