This script should remove the contents of the dustbin directory.
-a option is used the script should remove all files from the dustbin.
Otherwise, the script should display the filenames in the dustbin one by one and ask the user for confirmation that they should be deleted.
if test ! -f ~/TAM/dustbin/* then echo "this directory is empty" else for resfile in ~/TAM/dustbin/* do if test -f $resfile ; then echo "Do you want to delete $resfile" echo "Y/N" read ans if test $ans = Y ; then rm $resfile echo "File $resfile was deleted" fi fi done fi
The above is working, however it causes a few errors to be reported even though it still carries out the code on the next line after the error without crashing.
./remove: line 4: test: to many arguments
(This happens when there are more than 2 files in the dustbin.)
./remove: line 4: test: root/TAM/dustbin/NewFile2: binary operator expected
(This happens when the file is newfile2 but not newfile3.)
Also does anyone have any input on how I could do the
-a to delete everything in the folder without asking about each file separately?