I am writing a bash script to copy/move a folder called "folder" to a directory that already contains "folder" and I would like the contents to be merged.
I am attempting to use a solution from this question:
cp -rl source/folder destination
rm -r source/folder
If i type the first line in the terminal, source "folder" and destination "folder" are merged as expected.
However, When i run the script with the line in it, instead of merging the folders the destination now contains two folders; "folder" and "blank", where "blank" has the contents of the source "folder" in it.
source/folder
was not copied todestination/folder
? – Freddy Nov 03 '19 at 01:46cp "$source" "$destination"
rather thancp $source $destination
- the latter, without the double-quotes, will fail in all sorts of cases that the former, with quotes, will handle without problem). see Why does my shell script choke on whitespace or other special characters?