4 ms·
Instead of wrapping sed with a bash script to get multiple expressions to do their things, I normally use 'sed -e'. sed -e s/a/A/ -e s/foo/BAR/ -e s/hello/HELL
by mgerdts 5y ago
Instead of wrapping sed with a bash script to get multiple expressions to do their things, I normally use 'sed -e'.
sed -e s/a/A/ -e s/foo/BAR/ -e s/hello/HELLO/
I use -e often enough that I usually use -e whether I expect to use more than one expression or not. There's a reasonable chance that I will be going back into my history and will need to add another, which is easier if the first -e is already there.
Also, 'sed -e expr1 -e expr2' gives the same results as
'sed expr1 | sed expr2'. In both cases, the order of the expressions matter: later expressions may change things altered by the first.
$ echo foo | sed -e 's/f/g/' -e 's/goo/go/'
go
- ephaeton 5y agoThen there's sed -e 'cmd;cmd;cmd' as well.