我有一个脚本,该脚本应该在后台运行命令,并且可以执行该命令。问题在于,当脚本执行读取命令时,它不会暂停并接受输入。这里是:
printf "Where is yo music?: "
read musicPath
cd $musicPath
ls | while read currentSong;do
seconds=`mdls "$currentSong"|sed -n '20p'|awk '{print $3}'|cut -d. -f1`
hours=$((seconds / 3600))
seconds=$((seconds % 3600))
minutes=$((seconds / 60))
seconds=$((seconds % 60))
echo "Song: $currentSong"
echo "Length: $hours:$minutes:$seconds"
afplay "$currentSong"&
printf "yes (y), no (n), or maybe (m): "
read choice
case $choice in
y)
mkdir ../Yes
mv "$currentSong" ../Yes
;;
n)
mkdir ../No
mv "$currentSong" ../No
;;
m)
mkdir ../Maybe
mv "$currentSong" ../
;;
*)
echo "Invalid option! Continuing..."
;;
esac
kill $!
done
read -p "where is yo music? " musicPath