为什么这个 bash 脚本读取行代码会给我错误?
read -p "Does this require cropping? (y/n)? " answer
case ${answer:0:1} in
y|Y )
mkdir cropped; for i in *.mp4; do ffmpeg -i "$i" -filter:v "crop=1900:1080:-20:0" cropped/"${i%.*}.mp4"; rm -r *.mp4; cd cropped; cp -r *.mp4 ../
;;
* )
mkdir no
;;
esac
当我给出答案时,我从终端得到这个:
Does this require cropping? (y/n)? n
/usr/local/bin/prep: line 17: syntax error near unexpected token `;;'
/usr/local/bin/prep: line 17: ` ;;'
但是,如果我执行的(是)答案代码被更改为类似的内容,而不是整个mkdir cropped; for i in *.mp4...
,那么它工作得很好:
mkdir yes
答案1
您缺少循环done
中的the for
,因此no )
and stuff 是循环的一部分。