0

I'm trying to download some files over ssh. Files are in folders (folder1 folder2 folder3), so I decided to loop.

The following doesn't work:

ssh user@remotehost 'for i in 1 2 3; for filename in /folder$i/*.log; do cat /$filename > /localdrive; done; done;'

Any hint? Thanks!

  • Not going to work. the `/localdrive` is going to be `remotehost:/localdrive`. The ENTIRE command inside the `'` goes over to the remote host.You'd need to do something more like `for (...) do scp user@remotehost:remotefile localfile` instead. – Marc B Feb 21 '14 at 21:52
  • scp intends "localfile" on the remote host too :( – user3339059 Feb 21 '14 at 22:30

1 Answers1

1

Try

rsync -e ssh --include '*.log' --exclude '*' username@yourserver:/folder[1-3]/ /'yourlocaldirectory'

Rysnc uses scp internally.

OR for AIX system(as yours): Use:

scp remote:"/folser[1-3]/*.txt" local:/'yourlocaldirectory'

Hope it resolves your issue!

Amar
  • 2,171
  • 1
  • 13
  • 16