Zbyt wiele błędów argumentów w bashu
Piszę skrypt, aby usunąć wszystkie pliki w katalogu do praktyki. Używam cudzysłowów wokół moich zmiennych, a mimo to wciąż pojawia się następujący błąd:
/usr/local/bin/deleteall: line 6: [: too many arguments
/usr/local/bin/deleteall: line 11: [: too many arguments
Oto mój kod:
#!/bin/bash
#Deletes all files in the current directory
read -p "You are about to delete all files in $(pwd). Are you sure you want to do this? y/n" yn
echo $yn
if [ [ "$yn" = "y" ] -o [ "$yn" = "Y" ] ] ; then
for i in `ls`; do
rm $i
done
exit;
elif [ [ "$yn" = "n" ] -o [ "$yn" = "N" ] ] ; then
exit;
else
read -p "Please enter y (yes) or n (no)"
exit;
fi
I to jest cała produkcja:
You are about to delete all files in <my dir>. Are you sure you want to do this? y/nn
n
/usr/local/bin/deleteall: line 6: [: too many arguments
/usr/local/bin/deleteall: line 11: [: too many arguments
Please enter y (yes) or n (no)n
Co ja robię źle?