Is it possible to get files list that were downloaded using scp -r ?
Example:
$ scp -r $USERNAME@HOSTNAME:~/backups/ .
3.tar 100% 5 0.0KB/s 00:00
2.tar 100% 5 0.0KB/s 00:00
1.tar 100% 4 0.0KB/s 00:00
Expected result:
3.tar
2.tar
1.tar
The output that
scpgenerates does not seem to come out on any of the standard streams (stdout or stderr), so capturing it directly may be difficult. One way you could do this would be to makescpoutput verbose information (by using the-vswitch) and then capture and process this information. The verbose information is output on stderr, so you will need to capture it using the2>redirection operator.For example, to capture the verbose output do:
Then you will be able to filter this output with something like this:
The
awkcommand simply prints the last word on the relevant line. If you have spaces in your filenames then you may need to come up with a more robust filter.