I'm writing a bash script and in it I'm doing something like the following:
#!/bin/sh
read -p "Enter target directory: " target_dir
cp some/file.txt $target_dir/exists/for/sure/
When I run this shell script I see and input:
./my_script.sh
Enter target directory: ~/my_dir
But I get the error/output:
cp: directory ~/my_dir/exists/for/sure/ does not exist
And, as I'm trying to make obvious: That directory 100% exists. i.e. I can run the following without receiving any error:
cd ~/my_dir/exists/for/sure/
What's going on here?