Unix sftp - mput command - transfer all files with a specific prefix Unix sftp - mput command - transfer all files with a specific prefix unix unix

Unix sftp - mput command - transfer all files with a specific prefix


If your files all in current directory:

sftp user@server << EOFcd /destination$(for i in ABC* XYZ*; do echo "put $i"; done)EOF

Output (example):

Connected to server.sftp> cd /destinationsftp> put ABCfoo.txtUploading ABCfoo.txt to /destination/ABCfoo.txtABCfoo.txt                                                                100%    0     0.0KB/s   00:00    sftp> put XYZfoo.txtUploading XYZfoo.txt to /destination/XYZfoo.txtXYZfoo.txt                                                                100%    0     0.0KB/s   00:00  


Simply use a file mask in sftp put command (or mput alias):

cd /destination/pathput ABC*put XYZ*

Note that contrary to common command-line ftp client, in OpenSSH sftp the put itself can upload multiple files (and mput is just an undocumented alias to put).