I have a bash script which copies several files to a remote server using scp. This script works fine but now I need to add a file that contains a wildcard in the name and i have a problem with it.
#!/bin/sh
files=('path1/subpath/file.*.ext' 'path2/subpath2/nowildcard.ext2' 'path3/subpath3/file3.*.ext3');
for j in "${files[@]}"; do
echo "File \033[1;38;5;226m$j\033[0m is copying."
scp -P12345 $j "name@host:/permanent/path/$j";
done
The script copies the files with wildcard (e.g. file.12345.ext or file3.4321.ext3) but saves on the remote server as file.* .ext and file3.*.ext3. I tried to use a backslash in the file names but in this case the script does not copy the files at all.
How to fix this issue?
Thanks in advance.