11
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sed コマンドで複数の条件-e, -E, -r(拡張正規表現)を指定する方法

Posted at

sed で複数の条件を指定したいときの方法。

-E, -r(拡張正規表現)を指定したときに -e と同じようにオプションをつなげていくと、
sed: -E: No such file or directory となったのでメモ。

:information_source: Mac 標準の BSD sed, Homebrew で入れた gnu-sed 4.7 に基づきます。

-e オプション

$ sed -e 's/aaa/bbb/g' -e 's/ccc/ddd/g' -e 's/eee/fff/g'

つなげでいくだけ。

$ sed -e 's/aaa/bbb/g; s/ccc/ddd/g; s/eee/fff/g'

; で区切っても良い。

-E, -r(拡張正規表現)オプション

$ sed -E 's/aaa/bbb/g; s/ccc/ddd/g; s/eee/fff/g'

; で区切らないとダメ。

参考文献

11
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?