所以我现在正在参加一个夏季的 Unix 简介课程,我们需要编写一个脚本,根据文件扩展名将文件组织到目录中。现在我遇到了一个似乎找不到的语法错误。这是我的脚本:
#!/bin/bash
echo -e "Are you sure you want to reorganize your files? (Y to continue)"
read response
if [ $response == "Y" ] ; then
echo "Organizing files!"
touch organize.log
echo "Organizing..." > organize.log
mkdir music
mkdir video
mkdir text
for filename in *
do
extension="${filename##*.}"
if [ extension == "mp3" ] || [ extension == "oog" ] || [ extension == "wav" ] ; then
echo "$filename --> music/$filename" > organize.log
mv $file music
elif [ extension == "wmv" ] || [ extension == "mov" ] || [ extension == "mpg" ] ; then
echo "$filename --> video/$filename" > organize.log
mv $file video
elif [ extension == "txt" ] ; then
echo "$filename --> text/$filename" > organize.log
mv $file text
done
echo "Finished organizing files!"
echo "Bye!"
else
echo "Ok then. Bye."
exit
fi
exit
我是 Unix 新手,所以我觉得这很难。如果有人可以给我任何提示,我将不胜感激。
这是新的错误:
organizefiles.sh: line 38: syntax error near unexpected token `done'
organizefiles.sh: line 38: ` done '