我有这个文件“time.txt”:
1:53 5:38
5:46 8:17
8:19 12:37
我希望在批处理任务中使用它,测试cmd是这样的:
awk '{ print "ffmpeg -i 1.mp4 -ss "$1" -to "$2" -y -c copy " }' time.txt
输出如下:
-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
有什么问题? (看起来字符串在被连接时会被覆盖。)
找到原因:
文件“time.txt”有 windows类型的新行字符,这会扰乱awk的工作。 将它们转换为 unix-type 后,awk运行良好。
答案 0 :(得分:1)
对我来说很好看
[/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
仅供参考:
[/c]$ echo $SHELL
/usr/bin/bash