0

I need to transfer a bunch of files from a production host to my local machine. I'm already in the directory that I need to transfer the files from. I know the names of log files that I need to transfer to my local machine. They are log.timestamp.hostnames and these tend to be long. How can I transfer in bulk using scp ? Is there an easier way than just typing the long file names ? Can I get it out from a filename ?

Phoenix
  • 8,695
  • 16
  • 55
  • 88

3 Answers3

6

Use wildcards:

scp log.* user@host:/target/directory
devnull
  • 118,548
  • 33
  • 236
  • 227
0

If you didn't want to copy over all of your files in the current directory (which would just be using ./*), what you could do is parse all of the files in your current directory and run a regular expression on it to match up log.timestamp.hostname then pipe that into scp. For the regex I found this example regex with find. To send big files here is an example: scp syntax. Something along the lines of:

scp $(find . -regextype sed -regex ".*/log\.[a-z0-9\-]\.[a-z0-9\-]") user@remote:~/ 

You will probably want to modify the regex to make it work.

Community
  • 1
  • 1
0

This command line execution option helped to solve my issue of transfering a subset of files. As the AIX unix does not provide the -regextype option with find I used the grep command instead in order to retrieve files tab1.msg to tab9 msg

scp $(find . -name "*" | grep tab.\.msg)  user@host:/tmp
talonmies
  • 70,661
  • 34
  • 192
  • 269