I keep getting this error message and don't understand why. How do I fix it. I am using the bash shell on a Unix system.
$ sed -i 's/ he/ she/g' S13a4sed
sed: illegal option -- i
I keep getting this error message and don't understand why. How do I fix it. I am using the bash shell on a Unix system.
$ sed -i 's/ he/ she/g' S13a4sed
sed: illegal option -- i
sed command parameter option i
is not available in some of the unix environment, for example SunOS
Just use like below it will work for you.
$ sed 's/ he/ she/g' S13a4sed
Just test it like below:-
echo " he is a girl" | sed 's/ he/ she/g'
Output
she is a girl
sed
's -i
option is a feature of GNU's sed
. Unfortunately you can't use it on your system. But you can use perl
as well:
$ cat S13a4sed
he is a girl
$ perl -pi -e 's/he/she/g' S13a4sed
$ cat S13a4sed
she is a girl
From here: sed -i + what the same option in SOLARIS