sed - Using grep to adjust timecode -


i'm trying change timecode found 1 format another, remove milliseconds off end of file , update it. remove milliseconds transcription timecode software , make pretty file client.

input looks this:

00:50:34.00>interviewer why ............... script?  00:50:35.13>john doe because of quality. 

so i'm trying use grep match timecode , got working following expression.

grep [0-9][0-9][:][0-9][0-9][:][0-9][0-9]\.[0-9][0-9] -p -o transcriptionfile.txt 

output looks this:

00:50:34.00 00:50:35.13 

so i'm trying take timecode , update file updated values like:

00:50:34 00:50:35 

how do that? should use pipe push on sed can update values in file?

i've tried use sed following command:

sed 's/[0-9][0-9][:][0-9][0-9][:][0-9][0-9]\.[0-9][0-9]/[0-9][0-9][:][0-9][0-9][:][0-9][0-9]/g' transcriptionfile.txt > outtranscriptionfile.txt 

i output puts in regexp in place timecode supposed be. ideas? how can trim last 3 digits off far right side of timecode before update file?

any tips or suggestions appreciated.

thanks :-)

with gnu sed:

$ sed -r 's/^([0-9]{2}:[0-9]{2}:[0-9]{2})\>\.[0-9]{2}/\1/' transcriptionfile.txt  00:50:34>interviewer why ............... script?  00:50:35>john doe because of quality. 

to edit file in place, add -i option:

sed -r -i 's/^([0-9]{2}:[0-9]{2}:[0-9]{2})\>\.[0-9]{2}/\1/' transcriptionfile.txt 

explanation:

  • [0-9]{2}: matches every 2 digits followed :. 3 occurences captured using brackets.
  • \>\.[0-9]{2} matches > followed dot , 2 digits.
  • using backreference \1, strings matching previous pattern replaced captured characters (timecode without milliseconds).

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -