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.
ドキュメント内に 10 文字の単語があり、最初にそれを見つけてから 5 文字の単語に置き換えたいと考えています。シェルスクリプトでこれを行う最も効率的な方法は何ですか?
この sed ワンライナーは、最初の 10 文字の単語で置換を行います。
sed -r 's/\b\w{10}\b/55555/'
同じ例:
kent$ echo "The quick brown fox jumps over the obligatory dog."|sed -r 's/\b\w{10}\b/55555/' The quick brown fox jumps over the 55555 dog.