I have multiple directories with the same file (remote) and I want to copy them to multiple directories on my local machine.
So lets say remote I have
~/remote_folder/folder1/Myfile.log ~/remote_folder/folder2/Myfile.log ~/remote_folder/folder3/Myfile.log
Do note that next to Myfile.log there are also other files in the folder directories.
And local I want:
~/local_folder/folder1/Myfile.log ~/local_folder/folder2/Myfile.log ~/local_folder/folder3/Myfile.log
Here I only want the Myfile.log and not the other files from the remote.
So what I first had was (I use a bash script):
for folder in ~/remote_folder/*/ do dirr="$(basename $folder)" scp "$folder"Myfile.log user@host:~/local_folder/"$dirr"/ done
However this only works for the first 5 folders and then I get connection refused, probably because to many ssh connections.
Does there exist something that I could do this
scp ~/remote_folder/*/Myfile.log user@host:~/local_folder/*/
or something similar, but at least that I can do it with only one ssh connection?