I am totally new to bash scripting but wanted to give it a try. I wrote a simple and quick script for a backup of a directory.
#!/bin/bash
echo "Enter your source"
read source
echo "Enter your target"
read target
backup(){
cp -r $source $target
}
backup source target
exit 0
However, once I run it it doesn't recognize the directory path. It gives out: cp: cannot stat '~/Desktop/week46': No such file or directory
Even though the directory exists and when i manually run cp -r ~/Desktop/week46 ~/Desktop/week47
it is working.
What am I doing wrong?