I have the following function inside a BASH script (running under Ubuntu 12.x), which would copy over a file with spaces inside the file name. It's not working. I've tried many different combinations, with "', with \", etc. How do I get this to work? Thanks!
function copy_docs()
{
source_directory=/mnt/someplace
release_directory=/doc/someotherplace
cp ${source_directory}/"Some file with spaces.txt" ${release_directory}/
}
This is what I'm getting as output (from nearly all permutations):
cp: cannot stat `/mnt/someplace/some': No such file or directory
cp: cannot stat `file': No such file or directory
cp: cannot stat `with': No such file or directory
cp: cannot stat `spaces': No such file or directory
cp ${source_directory}/"Some\ file\ with\ spaces.txt" ${release_directory}/set -x; copy_docs; set +xcp: cannot stat /mnt/someplace/some: No such file or directorydoes not match the file name in yourcpstatement."Some file with spaces.txt"is not the same as"some file with spaces.txt"which is what your output suggests you are attempting to copy.