Bash

為什麼這個 bash 腳本讀取行程式碼給我錯誤?

  • May 26, 2019

為什麼這個 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

你錯過了doneon 你的for循環,所以no )and 東西是循環的一部分。

引用自:https://unix.stackexchange.com/questions/521106