I can successfully execute this command from the terminal:
sudo cp -R -u "/media/gabriela/Windows/Data/Untitled Folder" /media/gabriela/USB
But the following script does not work, with the appropriate entries entered:
sudo bash /home/gabriela/Desktop/copyfolder.sh
(to start the script, not part of the script)
read source
read destination
cp -R -u source destination
The error message says, cp: cannot stat 'source': No such file or directory
.
This is with the exact same info entered as in the plain cp
command which works.
"$source"
and"$destination"
rather thansource
anddestination
- but it is usually preferable to pass arguments to the script (see for example Passing arguments to a script) rather than read them interactively