0
-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?

alanc
  • 4,102
  • 21
  • 24
1337
  • 9
  • 4
  • `sed '$ a\sedtest' sed > tmp && mv tmp sed`? – Joachim Isaksson Jul 03 '19 at 19:23
  • please make sure if this is already answered somewhere else or easily googled: https://stackoverflow.com/questions/3576380/alternative-to-sed-i-on-solaris – Snedden27 Jul 03 '19 at 20:08
  • 1
    `-i` is a non-standard, non-portable GNU extension to the [POSIX standard `sed` utility](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html). – Andrew Henle Jul 04 '19 at 01:59

1 Answers1

1

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.

alanc
  • 4,102
  • 21
  • 24
  • 1
    Thanks, Alanc, that's exactly what I am looking for. I tried your solution and booomm it is working. Also now I can use /usr/xpg4/bin/sed @alanc Thanks – 1337 Jul 04 '19 at 22:19