Skip to main content

Command Palette

Search for a command to run...

Living in the Shell #15; sed (Text Stream Editor) (Part 2)

Updated
โ€ข1 min read
Living in the Shell #15; sed (Text Stream Editor) (Part 2)

sed ๐Ÿ–Š๏ธ

Edits streams by applying commonly used modifications.

Replace substring s

cat some-file.txt | sed 's/me/you/g'

Replaces all occurrences of "me" with "you".

Replace pattern s

echo "about\nabuse\namount" | sed 's/a\(\w*\?\)\w/\1/g'
bou
bus
moun

\1 refers to the first captured group.

Transform to lowercase \L

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 \U

cat some-file.txt | sed 's/.*/\U&/g'

Transforms all letters into uppercase.

F
felicia124y ago

Glad I found out about this article, it's very well structured. The slope game is a fun game that features a running ball. It is a popular game that is enjoyed by individuals of all genders and ages. The game is certain to give you a thrill, as seen by the large fan following.

More from this blog

Babak K. Shandiz's Blog

43 posts