17
13

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 - マッチした文字列を再利用する - 行末に文字列を追加する

Last updated at Posted at 2014-07-25

ほんとよく忘れるのでメモしておきます。

sed

  • マッチした文字列を再利用する
    • \(対象文字列\) とするとマッチした文字列は \1 \2.. と指定すると再利用できる
test.txt
aaaa
bbbb
sed -i -e "s/\(^bb.*$\)/\1 add a postscript/g" test.txt

sed実行後

test.txt
aaaa
bbbb add a postscript

17
13
1

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
17
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?