Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a lot of files named like:

/var/log/foo/2014-07-06-01.log
...
/var/log/foo/2014-07-20-04.log

Everyday I have several log files and I want to download specified day's log files:

$ rsync server:/var/log/foo/2014-07-06-*.log .

BUt I got zsh: no matches found error.

I found in the manual that I can filter by extension, but I couldn't find how to filter file name in case like this.

Is there easy way to use filtering with rsync?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You need to escape the special characters, e.g.

$ rsync server:/var/log/foo/2014-07-06-\*.log .

or

$ rsync 'server:/var/log/foo/2014-07-06-*.log' .

Or better, install url-quote-magic, e.g.

autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic
zstyle ':urlglobber' url-other-schema http https ftp mailto

so that zsh will automatically do this for you. You may want to add other URL schemes...

EDIT: Alternatively, you can unsetopt NOMATCH, so that an error falls back to POSIX shell behavior, but I would discourage you to do that, because it could lead to unexpected results in some cases.

share|improve this answer

Another way:

$ noglob rsync server:/var/log/foo/2014-07-06-*.log .

From zsh man page:

noglob   Filename  generation  (globbing)  is not performed on any of the
         words.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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