sed 用于在 AIX 6.1 中匹配模式后替换字符串 2 行

Jav*_*Red 1 sed aix

我尝试在匹配模式后替换 2 行字符。为此,我正在使用此代码:

sed '/some_pattern/{N;N;s/word1/word2/}' /etc/filesystems > /etc/filesystems.tmp && mv -f /etc/filesystems.tmp /etc/filesystems
Run Code Online (Sandbox Code Playgroud)

我测试了这个命令并确认它在 Linux 上运行良好。但是,当我在 AIX 中使用它时,我收到如下错误消息:

sed: Function /some_pattern/{N;N;s/word1/word2/} cannot be parsed.
Run Code Online (Sandbox Code Playgroud)

任何的想法?

meu*_*euh 5

AIX sed 需要将每个命令放在单独的行上。请参阅手册页 并尝试

sed '/some_pattern/{
 N
 N
 s/word1/word2/
}'
Run Code Online (Sandbox Code Playgroud)