This is snippet of the file I'm trying to change:
Code:
1: 00:02:43:24 00:02:45:22 01:23
Why haven't you ever asked me
Warum hast du mich nie gefragt,
2: 00:02:46:03 00:02:49:04 03:01
what this film is about?
worum es in diesem Film geht?
3: 00:02:53:16 00:02:58:18 05:02
And why haven't I ever told you, anyway?
Und warum hab ich es dir eigentlich nie erzählt?
4: 00:03:02:13 00:03:07:00 04:12
Was it just you not being curious?
Warst du einfach nicht neugierig?
5: 00:03:09:09 00:03:12:00 02:16
Or also me being relieved
Oder war ich einfach erleichtert,
What I'm trying to do is to delete the colon, add a new line and delete the empty space before the time interval, so that the line starts with that line interval, like this:
Code:
1
00:02:43:24 00:02:45:22 01:23
I'd like to do it with sed. This is what I've tried so far:
Code:
sed -r -e '/^[0-9]+:/{N;s/(^[0-9]+):\n\s+/\1\n}' file.txt
I've also tried using \t+ instead of \s+, but to no avail. There's no match, the text doesn't change at all.
On the other hand, I'm not sure using \n on both sides of the substitute sentence is going to work.
I did manage to create a new line after the number with each those lines begin, but I wasn't able to delete the space that preceeds the time interval, so that's not effective:
Code:
sed -r -e '/^[0-9]+:/{N;s/(^[0-9]+):/\1\n/g}' file.txt
1
00:02:43:24 00:02:45:22 01:23
Why haven't you ever asked me
Warum hast du mich nie gefragt,
Any ideas?
[later edit]
Now I've realised that the initial idea doesn't make sense, as there is no \n in the initial line, so there can't possibly be a match there.
So this seems to be doing what I'm looking for
Code:
sed -r -e '/^[0-9]+:/{N;s/(^[0-9]+):\s+/\1\n/g}' file.txt