I was connected my OpenSSH, but What's the command for ssh to find all files which are *.png and get them at the same time, recursively
I was connected my OpenSSH, but What's the command for ssh to find all files which are *.png and get them at the same time, recursively
You can list files of your interest with ssh
, then download them with scp
:
ssh user@host find /remote_path -iname '*.png' |
while read pngfile; do
scp user@host:"$pngfile" /local_path
done
All *.png
files under /remote_path
will be downloaded to /local_path
, but the remote directory structure will not be created (all files will be put in the same directory), so you may have problems if you have two files with the same name in different directories.
Edit
The remote find
command line should be corrected in this way:
find /remote_path -iname "'*.png'"
where the internal pair of single quotes are needed to avoid local shell pathname expansion of *
, wheras the external pair of double quotes are needed to avoid remote shell pathname expansion of *
.
The two types of quotes could be exchanges, and other syntaxes could be used, like ''*.png''
, ""*.png""
or ""*.png""
.
If you don't have .png in remote home directory, there is no difference between the two commands, but it is better to be safe.