考虑这个示例文件:
01
00:00:00,000 --> 00:00:00,000
Alphabetic characters.
02
00:00:00,000 --> 00:00:00,000
Alphabetic characters
Alphabetic characters,
03
00:00:00,000 --> 00:00:00,000
Alphabetic characters,
我只想在一行文字中添加字符串。
01
00:00:00,000 --> 00:00:00,000
<fc=ff00 >Alphabetic characters,
02
00:00:00,000 --> 00:00:00,000
<fc=ff00>Alphabetic characters
Alphabetic characters,
03
00:00:00,000 --> 00:00:00,000
<fc=ff00>Alphabetic characters,
使用sed: sed&#39; / [[:alpha:]] / s / ^ //&#39;文件&gt; new_file
我不清楚如何排除第二行。有什么建议吗?
答案 0 :(得分:1)
$ awk '!f && /[[:alpha:]]/{print "<fc=ff00>" $0; f=1; next} {print; f=0}' file
01
00:00:00,000 --> 00:00:00,000
<fc=ff00>Alphabetic characters.
02
00:00:00,000 --> 00:00:00,000
<fc=ff00>Alphabetic characters
Alphabetic characters,
03
00:00:00,000 --> 00:00:00,000
<fc=ff00>Alphabetic characters,