Link to home
Create AccountLog in
Avatar of MIHIR KAR
MIHIR KARFlag for India

asked on

How to SFTP multiple file from source to dest in Linux?

Hi Expert,

I have a SFTP job which is failing while transfer file for source to dest using "put" command.  As put command only works for single file.

Here my requirement is i want to transfer all the files available in "source/dir1/dir2" and want to merge them into single file then wanna SFTP.

Note:The script should also need to check how many files are there in the source directory before merge them!

thanks in advance.
Avatar of David Favor
David Favor
Flag of United States of America image

Use mput rather than put.
Hi,

Your question is not clear,

you want to merge all files into one file then transfer? Why?

Also, below is not clear:

"The script should also need to check how many files are there in the source directory before merge them!"
Avatar of noci
noci

if sftp is used how about:   (sftp uses ssh links underneath, so scp should also work).

scp /from/where/ever/* user@remote_system:/to/dest/

Open in new window

recursive with:
scp -r /from/where/ever/* user@remote_system:/to/dest/

Open in new window

You would tar the files up at the source first, then put it on the destination

tar -czf transferfile.tgz source/dir1/dir2
then you can put transferfile.tgz in the destination.

You probably should be using rsync for this instead, as that will allow you to continue after an interruption.  rsync -az source/dir1/dir2 destination/
ASKER CERTIFIED SOLUTION
Avatar of kenfcamp
kenfcamp
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account