Bash-sed-examples

From I Will Fear No Evil
Revision as of 06:17, 8 July 2024 by Chubbard (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Examples of using sed for different jobs

Remove all of a string until first match

echo "1=2=3" | sed 's/[^=]*=//'
2=3

Stackexchange Details

Remove all after LAST match

echo "foo.bar.baz" | sed -e 's/\.[^.]*$//'
foo.bar