Case-insensitive search and replace with sed

前端 未结 8 1909
暗喜
暗喜 2020-11-28 08:51

I\'m trying to use SED to extract text from a log file. I can do a search-and-replace without too much trouble:

sed \'s/foo/bar/\' mylog.txt
<
8条回答
  •  旧巷少年郎
    2020-11-28 09:49

    Editor's note: This solution doesn't work on macOS (out of the box), because it only applies to GNU sed, whereas macOS comes with BSD sed.

    Capitalize the 'I'.

    sed 's/foo/bar/I' file
    

提交回复
热议问题