I want to copy a folder from a server , but not all files .

e.g I have folder named xyz | and contents of folders are as below :

and so on

And I want to copy whole folder except abc.conf and rfc.conf. How can I do this ?

  • You forgot 1 thing: HOW do you copy these files? scp? telnet? ftp? winscp? a browser? filezilla? Why not copy all and remove those 2 when done? Less hassle ;-) – Rinzwind Oct 10 '16 at 6:37
  • Why can't you just delete the files after copying them, as @Rinzwind suggested? – Kaz Wolfe Oct 10 '16 at 6:40
  • I am using scp to copy , It's just example I have long list of file for removing it from list. i.e. I just not have two file to delete from list. – Avani badheka Oct 10 '16 at 6:41
  • @Avanibadheka and there you have a big problem. you will need to supply -all- the exceptions to scp. Not the correct tool when you need to type all the exceptions ;) – Rinzwind Oct 10 '16 at 6:52

If you can use rsync, you can grab all files from a folder, excluding a certain list using this command:

rsync -a --exclude-from=path/to/excludes.txt myuser@myserver:/path/to/files/ .

Be sure that path/to/excludes.txt is a text file like so:


Note that this excludes file is stored locally, so you must grab it from the server first if you don't have it.

Otherwise, such a task is not possible without heavy SCP mangling and shell scripting using xargs and the like.

  • That's correct , but if I have list of file to exclude at a time. I used your command for single file excluding. – Avani badheka Oct 11 '16 at 12:19

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.