Tuesday, May 7, 2019

Copying multiple files with scp

You can copy all files in directory but problem is when you are trying to copy several files from huge directory. Below is the method I use to achieve needed:
  1. save list of names of needed files with their paths into the test file (ex: scpList.txt) - full path is needed!
  2. assign this list to the variable: scpList=$(echo \";for file in $(cat scpLoad.txt); do printf $file ; printf " "; done; echo \")
  3. manually copy variable content: echo $scpList
  4. mkdir ~/Desktop/scpFiles
  5. scp root@srvIP:insertCopiedVariableContentHere ~/Desktop/scpFiles 

No comments:

Post a Comment