小さな編集文字列を含むファイルから行をコピーする方法を見つける必要があります。レプリカは元の行の上に表示する必要があります。それが最善の選択でしょうかsed
?awk
理想的には、新しいpuppies
行に置き換えて交換することをお勧めします。bunnies
I
You
たとえば、
- 入力ファイル:
I have puppies cute I have two kitties I have three puppies cute I have four kitties
- 結果は次のとおりです。
You have bunnies cute I have puppies cute I have two kitties You have three bunnies cute I have three puppies cute I have four kitties
ベストアンサー1
GNUの使用sed
:
sed 'h; s/puppies/bunnies/g; T; s/I/You/; G' < your-file