特定の値をsedに置き換える

特定の値をsedに置き換える

何百もの$

$ cat /tmp/file

$one $t $three
$one $t $three $t $three

sedで始まる値のみを変更しようとします$t

$ sed "s/\$t/foo/g" /tmp/file

$one foo foohree
$one foo foohree foo foohree

ただし、上記のコマンドは$threeこれらの値も置き換えます。これが起こらないようにするにはどうすればよいですか?

ベストアンサー1

努力する:

sed "s/\$t\>/foo/g" /tmp/file

\>単語の終わりの正規表現パターンの一致。

おすすめ記事