Search code examples
solaris

How to use "SED -i" in solaris?


-bash-3.2$ cat sed
A
B
C
D
-bash-3.2$ sed -i '$ a\sedtest' sed 
sed: illegal option -- i
-bash-3.2$

I cant use { echo "sedtest" >> sed }

-bash-3.2$ cat sed A B C D -bash-3.2$ sed -i '$ a\sedtest' sed sed: illegal option -- i -bash-3.2$

Any solution using awk/perl/sed?


Solution

  • The -i flag is an addition of GNU sed over the traditional Unix sed. On Solaris 11, you can use GNU sed by running /usr/gnu/bin/sed - on Solaris 10, you'll need to install the GNU sed open source package as it's not provided with the OS.