![删除文件中的计数器行号和时间线](https://linux22.com/image/147874/%E5%88%A0%E9%99%A4%E6%96%87%E4%BB%B6%E4%B8%AD%E7%9A%84%E8%AE%A1%E6%95%B0%E5%99%A8%E8%A1%8C%E5%8F%B7%E5%92%8C%E6%97%B6%E9%97%B4%E7%BA%BF.png)
我有一个电影的字幕(sub.srt 或文本文件)文件。但我想知道是否有一种简短的方法可以删除文件的所有行号和时间线。例如
85
00:07:39,250 --> 00:07:41,469
We got to be smart.
We're a ways from being finished.
86
00:07:41,628 --> 00:07:43,380
Shit, I can do this all week.
87
00:07:43,546 --> 00:07:44,547
We're gonna.
88
00:07:44,714 --> 00:07:49,352
We're like the Comanches,
little brother, raiding wherever we please
它必须被证明为
We got to be smart.
We're a ways from being finished.
Shit, I can do this all week.
We're gonna.
We're like the Comanches,
little brother, raiding wherever we please
我怎样才能达到这个目标?
答案1
使用 的awk
段落模式 ( RS=
) 会使每个行块被视为输入记录。此外,字段分隔符可以设置为\n
从 3 开始打印的字段 - 这假设行号和时间线始终出现在每个记录块内的前两条记录中
awk -F '\n' -v RS= '{for (i=3; i<=NF; ++i) print $i; print ""}' file
We got to be smart.
We're a ways from being finished.
Shit, I can do this all week.
We're gonna.
We're like the Comanches,
little brother, raiding wherever we please