파일에서 카운터 줄 번호 및 타임라인 제거

파일에서 카운터 줄 번호 및 타임라인 제거

영화에 대한 자막(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=각 줄 블록이 입력 레코드로 처리됩니다. 또한 필드 구분 기호는 3부터 인쇄되는 필드로 설정할 수 있습니다 \n. 이는 줄 번호와 타임라인이 항상 각 레코드 블록 내의 처음 두 레코드에 나타나는 것으로 가정합니다.

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

관련 정보