Issue
I have thousands on many lines in a text file. Some consist of 2 lines, some have 1 line, as seen below:
1
00:01:18,479 --> 00:01:20,514
Dr. Oppenheimer.
2
00:01:24,052 --> 00:01:25,653
As we begin, I believe you have
3
00:01:25,686 --> 00:01:27,688
a statement to read
into the record.
4
00:01:29,523 --> 00:01:30,725
Yes, Your Honor.
5
00:01:30,758 --> 00:01:32,861
We're
not judges, Doctor.
6
00:01:32,895 --> 00:01:33,929
Of course.
......so on and on...........
I want to know how to convert a sentence that only consists of 2 lines into one line so that the final result is like this:
1
00:01:18,479 --> 00:01:20,514
Dr. Oppenheimer.
2
00:01:24,052 --> 00:01:25,653
As we begin, I believe you have
3
00:01:25,686 --> 00:01:27,688
a statement to read into the record.
4
00:01:29,523 --> 00:01:30,725
Yes, Your Honor.
5
00:01:30,758 --> 00:01:32,861
We're not judges, Doctor.
6
00:01:32,895 --> 00:01:33,929
Of course.
......so on and on...........
Solution
$ awk -F'\n' -v OFS='\n' -v RS= -v ORS='\n\n' 'NF==4{$3=$3" "$4; NF=3}1' file
1
00:01:18,479 --> 00:01:20,514
Dr. Oppenheimer.
2
00:01:24,052 --> 00:01:25,653
As we begin, I believe you have
3
00:01:25,686 --> 00:01:27,688
a statement to read into the record.
4
00:01:29,523 --> 00:01:30,725
Yes, Your Honor.
5
00:01:30,758 --> 00:01:32,861
We're not judges, Doctor.
6
00:01:32,895 --> 00:01:33,929
Of course.
Answered By - ufopilot Answer Checked By - Candace Johnson (WPSolving Volunteer)