"-f ._filterlist" syntax

raf rsync at raf.org
Mon Sep 28 03:20:37 UTC 2020

On Sun, Sep 27, 2020 at 03:19:17PM -0700, Will McGinnis via rsync <rsync at lists.samba.org> wrote:

> Hello, A GUI program uses rsync for network transfers. It is able to
> load  filters from a file by putting a dot and underscore before it.
> Example:mkdir 1 2; touch 1/a .empty; rsync -f ._empty 1/ 2/
> Is the dot underscore specific to rsync or is it a general bash (or
> similar?) feature to load arguments from a file? And is it documented
> anywhere for rsync?

>From the manpage:

    Rsync builds an ordered list of filter rules as
    specified on the command-line. Filter rules have
    the following syntax:


    You have your choice of using either short or long
    RULE names, as described below. If you use a
    short-named rule, the ',' separating the RULE
    from the MODIFIERS is optional. The PATTERN or
    FILE- NAME that follows (when present) must come
    after either a single space or an underscore (_).
    Here are the available rule prefixes:

    merge, '.'
      specifies a merge-file to read for more rules.

So the "." means load rules from a file, and the "_"
is like an alternative to a space for separating the
"." and the filename. It seems that the space isn't
optional when using the short form, like the comma is.

I think this is rsync-specific.

I have seen programs use a convention of an "@" prefix
to an option argument to indicate that the rest of the
option argument is a filename to read the real option
arguments from. And I have seen libraries that provide
command line option functionality with support for
config files for default options.

A general purpose way of getting command line options
from a file, if you have a shell available, is to store
command line options in a file like this:

  --optiona ...
  --optionb ...
  --optionc ...

And then use them with on the command line like this:

  cmd `cat cmd-options` args...


More information about the rsync mailing list