Is there a way I could transfer all files of a given extension with SSH?

0

3

do you know how I could transfer all files with a particular extension (ex. txt files) from a server and keep the folder sctructure using SSH Secure File Transfer?

I'm using Win 7 Pro 64-bit, and I do have some advanced knowledge in computing (if that's required).

Firebug

Posted 2013-10-02T15:31:27.120

Reputation: 310

@BrunoHeblingVieira 'file type' is ok. Maybe that commenter questioned what you meant because in your title you had written "from a given type" whereas 'of' would be the right term rather than from, Also though, file extension is technically better, if that's what you are specifying, and it is possible that a file's type isn't determined by its extension. The find command(the *nix one you can use via cygwin) might be able tp be amended to specify file type rather than extension i.e. regardless of extension. That would probably suit your purposes too – barlop – 2015-05-16T12:23:09.647

2What do you mean by file of the same type? – heavyd – 2013-10-02T15:40:50.260

1Thanks for editing the question, it seems file 'type' makes way more sense in portuguese than in english. – Firebug – 2013-10-02T16:52:57.410

Answers

1

SSH alone does not transfer files but it allows transferring a stream of data and running commands on the remote computer.

This means that you can use any utility which will transform your files into a stream of data pass the stream through SSH and on the other end do the reverse process - extract the files from the stream. Below is an example with tar.

find /source/path -iname "*.ext" -print0 |
  tar --null -cf- -T- |
  ssh user@machine "tar -xf- -C /path/to/extract"

The command sequence can be on single line I added newlines for better readability. Probably only GNU tar has the --null and -T options.

If you do not have the suitable tools on your Windows you can install for example Cygwin.

pabouk

Posted 2013-10-02T15:31:27.120

Reputation: 5 358

1

Just in case anyone sees this question, I was able to achieve the same thing with FileZilla, using the Filter options.

Firebug

Posted 2013-10-02T15:31:27.120

Reputation: 310