Sed on AIX does not recognize -i flag

后端 未结 6 1949
闹比i
闹比i 2020-12-07 01:39

Does sed -i work on AIX?

If not, how can I edit a file \"in place\" on AIX?

6条回答
  •  孤城傲影
    2020-12-07 02:35

    You can use a here construction with vi:

    vi file >/dev/null 2>&1 <<@
    :1,$ s/old/new/g
    :wq
    @
    

    When you want to do things in the vi-edit mode, you will need an ESC.
    For an ESC press CTRL-V ESC.
    When you use this in a non-interactive mode, vi can complain about the TERM not set. The solution is adding export TERM=vt100 before calling vi.

提交回复
热议问题