Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
このようなテキストがあります
HELLO WORLD(some_text、some_other_text)
上記のテキストの最後に16という数字をこのように追加したい
HELLO WORLD(some_text、some_other_text)16
私はこの正規表現^HELLO WORLD \(([a-z],[a-z])がそれに一致することを知っています。一致した正規表現を変数に格納してから16を追加する方法がわかりません。
^HELLO WORLD \(([a-z],[a-z])
&キャラクターはパターンスペースにすべてを保持します。
&
sed 's/^HELLO WORLD ([a-z_]*, [a-z_]*)/& 16/' file
一致する文字列としての&の使用をご覧ください
そして、\1を使用してパターンの一部を保持します