0

I have this file "time.txt":

1:53 5:38
5:46 8:17
8:19 12:37

and I want to use it in batch tasks, the test cmd is like this:

awk '{ print "ffmpeg -i 1.mp4 -ss "$1" -to "$2" -y -c copy " }' time.txt

The output is like this:

 -y -c copy mp4 -ss 1:53 -to 5:38
 -y -c copy mp4 -ss 5:46 -to 8:17
 -y -c copy mp4 -ss 8:19 -to 12:37

What is wrong? (It looks like the strings are overwritten when it should be concatenated.)

The cause found:

The file "time.txt" has windows-type new-line characters, which upsets awk's work. After converting them to unix-type, awk works well.

LiLei
  • 63
  • 6

1 Answers1

1

It looks good for me

[/c]$ awk '{ print "ffmpeg -i 1.mp4 -ss "$1" -to "$2" -y -c copy " }' time.txt

ffmpeg -i 1.mp4 -ss 1:53 -to 5:38 -y -c copy
ffmpeg -i 1.mp4 -ss 5:46 -to 8:17 -y -c copy
ffmpeg -i 1.mp4 -ss 8:19 -to 12:37 -y -c copy

FYI:

[/c]$ echo $SHELL
/usr/bin/bash
JRG
  • 4,037
  • 3
  • 23
  • 34
  • Thanks. The file has problem: new-line character is windows type. It works when they are converted to unix type. – LiLei Aug 19 '17 at 03:25