I am trying to copy any files with the extension .pf to another box. is it possible to do this and keep the file path structure too?

I tried

scp -rp /*.pf user@ 

but it fails with *.pf: No such file or directory



You should use rsync instead of scp because it offers more options:

rsync -avm --include="*/" --include="*.pf" --exclude="*" / user@

Unfortunately, it is a bit complicated when it comes to rsync's include and exclude parameters. Please refer to this question over on Stack Overflow for details.

They say (for *.sh files instead of *.pf files):

So if we only want *.sh files we have to exclude all files --exclude="*", include all directories --include="*/" and include all *.sh files --include="*.sh".

To get a preview first, add the -n switch to the call. This will instruct rsync to only tell what it would do whithout actually doing it:

rsync -avm -n --include … 

Further reference:

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.