I want to know how can I copy or shell copy multiple files within a bash script. What I mean is that
cp /path/to/source/{file1,file2,file3} /path/to/dest
and
scp /path/to/source/{file1,file2,file3} user@host:/path/to/dest
will work fine but as example
#!/bin/sh
scp /path/to/source/{file1,file2,file3} user@host:/path/to/dest
will throw an error like this:
/path/to/source/{file1,file2,file3}: No such file or directory
If you will copy or shell copy a single file it works, so the problem are multiple files. Also it works if I would use * for all files but I do not want to copy all files. I should only copy selected files because in both folders are files with the same name but their content is different. Thereby to copy all files and then remove the not needed files would not work.
For better understanding following would work:
#!/bin/sh
scp /path/to/source/file1 user@host:/path/to/dest
Also following:
#!/bin/sh
scp /path/to/source/* user@host:/path/to/dest
So it has something to do with the correct use of { ... } for multiple files which will work inside the terminal but not if I run the bash script in it.
Thanks in advance.
//Edit:
I add the error if I try it with cp:
cp: cannot stat '/path/to/source/{file1,file2,file3}': No such file or directory