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.
2nd または 3rd に住んでいるすべての人の後に STREET という単語を挿入したいので、2nd または 3rd はすべて 2nd STREET と 3rd STREET になります。私は sed コマンドを使用していますが、正しい構文を教えてください。最初の9行だけ欲しい
ありがとう
次のコマンドは仕事をするべきです
sed -r '1,9s/(2nd|3rd)/\1 STREET/g' file
これにより、最初の 9 行だけで検索と置換が実行されます。
編集
ファイルの最初の 9 ファイルのみが必要な場合は、head
head
head -n 9 file | sed -r 's/(2nd|3rd)/\1 STREET/g'