I am having a bit of a problem with a script I am trying to create.
This script should take two arguments which are the source directory and the destination directory and if the user enters less than 2 arguments it should print out an error message and exit. In addition this script should check if the source directory exists or not, if not it should print out an error message and exit. Also the script should check if the destination directory exists or not, if not it should create that directory. Finally the script should copy the files from the source directory to the destination directory.
This is my attempt so far:
if (( $# < 2 ));
echo "Error: Too few arguments supplied"
exit 1
if [ -d "src_dir" ]
then
echo "Directory src_dir exists."
else
echo "Error: Directory src_dir does not exist."
fi
if [ -d "dst_dir" ]
then
echo "Directory dst_dir exists."
else
mkdir dst_dir
cp -r src_dir/* dst_dir
fi
Any help would be really appreciated. Thanks in advance!