I created a script that checks if a certain directory exists; if not, then it is created. Then a for loop is used to run through all regular, non-hidden files in the current dir. If a file is empty, then prompt if the user would like it moved. Where I'm stuck is that the script, after running through the files, needs to check if all files are empty, and then displays a message saying so. Here's what I have.
#!/bin/bash if [ -d Empty_Files ] then echo "This file directory exists already. Move on" else mkdir Empty_Files echo "I created the Empty_Files directory since it didn't exist before" fi for file in `ls` do if [ ! -s $file ] then echo "Would you like" $file "moved to Empty_Files? It's empty! Enter Yes or No" read userinput if [ $userinput = "Yes" ] then mv $file ./Empty_Files fi if [ $userinput = "No" ] then echo "Ok, I will not move it!" fi fi done if [ -s $file ] then echo "There are no empty files!" exit 55 fi
As you can see, my
if statement at the end doesn't work fully as intended.