1

I try to replace a character, 2 lines after matching pattern. For this, I'm using this code:

sed '/some_pattern/{N;N;s/word1/word2/}' /etc/filesystems > /etc/filesystems.tmp && mv -f /etc/filesystems.tmp /etc/filesystems

I tested this command and confirmed it's working fine on Linux. However, when I use it in AIX, I receive an error message like:

sed: Function /some_pattern/{N;N;s/word1/word2/} cannot be parsed.

Any idea?

2 Answers 2

5

AIX sed needs each command on a separate line. See man page and try

sed '/some_pattern/{
 N
 N
 s/word1/word2/
}'
0
-1

This works for me

sed '/some_pattern/{N;N;s/word1/word2/;}'
1
  • Of course it does, since you're using GNU sed. GNU sed is not available on AIX unless it's installed separately.
    – Kusalananda
    Commented Jul 11, 2016 at 11:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .