
我想使用 find -exec 選項執行一些命令,但我不確定這段程式碼有什麼問題。目前,它只處理第一個查找結果,然後就卡住了。我在 OS X 中使用 bash。
read -e DIRECTORY
find $DIRECTORY -type f -name '*.mov' -exec sh -c '
file="$0"
echo "Processing $file ..."
modmovie -notrack "Timecode Track" $file -save-in-place
read line </dev/tty
' {} \;
答案1
我想出了這個例子,正如其他人在評論中所說,這read line </dev/tty
導致它等待用戶輸入。
#!/bin/bash
find db -type f -name '*.jpg' -exec sh -c '
file="$0"
echo "hi"
echo "$file"
read line </dev/tty
' {} \;
我的腳本的輸出
hi
db/db1440/gothamgardenxmas21440.jpg
<---- I hit enter here
hi
db/db1440/unveiling11440.jpg
<---- I hit enter here
hi
db/db1440/astronomer21440.jpg
<---- I hit enter here
...