I don't see the point in trying to diff the directories if the content is recursively moved.
It won't lose any files on the way.
Code:
#!/bin/bash
OPT=$1
SRC=$2
DST=$3
function usage {
echo "USAGE: $0 <-s|-m> [<source directory>] [<destination directory>] "
exit 0
}
function copy_dir {
SRC_DIR=$1
DST_DIR=$2
[ -d $DST_DIR ] && exit 1
# Add things here if you want extra features :)
cp -R $SRC_DIR $DST_DIR
# this takes the return code from "cp" and exits if it's not 0
[ $? -eq 0 ] || exit $?
}
case $OPT in
-s)
copy_dir $SRC $DST
;;
-m)
while [ true ]; do
echo "Write \"exit\" to exit program"
read -p "Source directory: " SRC
case $SRC in
[eE][xX][iI][tT]|[xX])
exit 0
;;
esac
read -p "Destination directory: " DST
copy_dir $SRC $DST
echo "- Copy done.";
done
;;
*)
usage
;;
esac
This pretty much just copies the files the way you want it too.
If you want to make some extra checks and things, then I suggest you edit the function "copy_dir".
In "-m" mode you can type in "exit" (in any case-format) in the "Source directory" field to exit it cleanly.
In "-s" mode it only takes commandline input (source and destination as described in the usage) and then exits
Best regards
Fredrik Eriksson