5

I want to sync some files from a remote server to my local computer. How can I make rsync to just copy the files with a certain file extension in the directory but no subdirectories?

I assumed this to be an easy task, but embarassingly I'm not getting it for nearly 2 hours. So could someone give me an example?

I did various experiments with something like the following command:

rsync -a --include=what? --exclude=what? -e ssh [email protected]:/test /test
1

2 Answers 2

5

If you just want one extension, in one directory, why not just use regular globbing?

rsync /home/you/rsync_this/*.jpg user@server:/remote/folder/

You can even copy multiple extensions with:

rsync /home/you/rsync_this/*.{jpg,png,gif} user@server:/remote/folder/
1
  • I was simply not aware of this... But it's acutally the easiest solution.
    – Michael
    Commented Aug 21, 2014 at 7:30
4

What about:

rsync $(pwd)/*.stuff  user@server:$(pwd)

$(pwd) will expand to the current dir on both sides and you will save yourself some typing ;)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .