Hi all new to the forums. Very beginner at shell scripting. What I'm trying to do is this:
Is the directory empty prior to removal of it? If not, inform the user that the directory is not empty and if the user wants to remove it remove or move the files in it first.
But I'm stuck.. It checks if its empty but how would I go about removing the directory after checking whether it is empty or not.
#!/bin/bash
echo "Please enter directory to be removed: "
read directory1
if [ "$(ls -A $directory1)" ]; then
echo -e "$directory1 is not empty!"
else
echo -e "$directory1 is empty!"
if [ $directory1 ]
fi