gianx80
October 22nd, 2011, 12:10 PM
Hi to all! I'm a novice to bash programming and I'm studying for an university exam about it. I solved an exercise, but I have a problem.
In my script I have 3 nested loops like these:
cat $FILENAME | while read LINE
do
cd $LINE
ls -p -1 > $TEMPFILE
cat $TEMPFILE | while read FILE
do
cat $TEMPFILE | while read OTHERFILE
do
rm -i $FILE
done
done
done
in the inner loop I have a rm -i command. What is the problem? If I remove the -i option the script works well and files are removed. If I use the -i option (as asked inn the exercise) the script prints to terminal the confirmation messages but it doesn't let me answer yes or no and ends its execution without deleting files.
I've already asked on Italian Ubuntu forums but nobody could help me.
Please help me :(
In my script I have 3 nested loops like these:
cat $FILENAME | while read LINE
do
cd $LINE
ls -p -1 > $TEMPFILE
cat $TEMPFILE | while read FILE
do
cat $TEMPFILE | while read OTHERFILE
do
rm -i $FILE
done
done
done
in the inner loop I have a rm -i command. What is the problem? If I remove the -i option the script works well and files are removed. If I use the -i option (as asked inn the exercise) the script prints to terminal the confirmation messages but it doesn't let me answer yes or no and ends its execution without deleting files.
I've already asked on Italian Ubuntu forums but nobody could help me.
Please help me :(