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.
特殊文字 (=) を最初に出現したときだけ置換したい。
例:
abc=abc.def=
予想される出力は次のとおりです。
abc.def=
次のコマンドを試しましたsed -e 's/\([^=]*\)\(=.*\)/\2/' が、得られる出力は次のとおりです。
sed -e 's/\([^=]*\)\(=.*\)/\2/'
=abc.def=
あなたの例は、最初の等号までのすべてを削除することを示唆していることに注意してください。
等号を正規表現の最初の部分に移動し、正規表現の残りの部分を削除し (削除する部分のみを一致させる必要があるため)、一致を「何もない」に置き換えて削除します。
sed -e 's/^[^=]*=//'