Reputation: 653
I'm trying to Add Characters to the end of certain lines of many text files. Sample of the Text (These are Subtitles)
WEBVTT
00:00.000 --> 00:03.000
Der perfekte Case sozusagen war,
00:03.000 --> 00:06.000
dass man in der gleichen Stadt wohnt, befreundet ist,
00:06.000 --> 00:08.000
sich 6 Monate nicht gesehen hat
....
I need to add L:90% to the end of each Timecode. (with a space at the beginning) I've come up with this Regex to mark the end of the correct lines, but I couldn't find out about the correct Syntax to add Stuff in the end.
(-->).*
Ive been using this:
sed -i '' 's/->/-->/g' */*.vtt
to find and replace through the terminal.
Thanks a lot! Vinni
Upvotes: 0
Views: 85
Reputation: 42760
This should do the trick:
sed -i 'bak' -Ee 's/(--> [0-9:.]+)/\1 L:90%/' */*.vtt
The \1
is a backreference to the stuff you captured inside the ()
. The -E
flag enables extended regular expression support. Otherwise the capturing doesn't work as well.
Upvotes: 2