Reputation: 21632
What is the difference between sed -i -e
and sed -ie
?
It's not very clear from help
sed --help
-e script, --expression=script
add the script to the commands to be executed
In second case it creates some backup file?
In general Unix utils do not permit to combine flags?
Just an example to show what is happening:
echo "bla" > 1.txt
cat 1.txt
bla
sed -i -e 's:bla:blakva:g' 1.txt
cat 1.txt
blakva
sed -ie 's:bla:blakva:g' 1.txt
cat 1.txt
blakvakva
*Note: also 1.txte is created, containing
cat 1.txte
blakva
Also not still sure what is -e
doing in my example, because sed -i 's:bla:blakva:g' 1.txt
works too.
Upvotes: 11
Views: 30108
Reputation: 14949
When you give sed -i -e
, sed
sees two options.
But, When you give sed -ie
, sed
sees -i
option only with suffix
as e
. That is the reason you got file backup with e
suffix.
From
man sed
:-i[SUFFIX], --in-place[=SUFFIX]
edit files in place (makes backup if SUFFIX supplied)
Upvotes: 14
Reputation: 364
Option -i
means that it modify in-place the file you are sed-ing. Otherwise sed
just show what modification were done. If you add a suffix after -i
(e.g -i.bck
) it will backup your input file then add the suffix provided.
Option -e
allow you to provide sed script instead of command line arguments.
Upvotes: 6