テキスト ファイルでは、perl を使用して、別のテキスト行が一致するたびに新しいテキスト行を挿入したいと考えています。
例 - 私のファイルは次のとおりです。
holiday
april
icecream: sunday
jujubee
carefree
icecream: sunday
Christmas
icecream: sunday
towel
...
'icecream: saturday'
'行の前にテキスト行を挿入したいと思いますicecream: sunday'
。その後、テキストファイルは次のようになります。:
はい、検索パターンと置換パターンの両方でコロンが必要です。
holiday
april
icecream: saturday
icecream: sunday
jujubee
carefree
icecream: saturday
icecream: sunday
Christmas
icecream: saturday
icecream: sunday
towel
...
Windows PC で perl 5.14 を使用してこれを行いたいと思います。私はすでにPerlをインストールしています。この Web サイトで他の多くの例を検索して試しましたが、うまくいきませんでした。残念ながら、私は Perl の完全な専門家ではありません。
sedも使用する例があれば、Cygwin sedも持っています。