Bash-sed-examples

From I Will Fear No Evil
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