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 file that rsync uses as --files-from:

dir1
dir2
dir3

I want to be able to put comments above each dir entry like that:

# my dir1 comment
dir1

#dir2 comment
dir2

#yet another comment
dir3

but rsync complains "No such file or directory"

So far I have tried #,//,--,,SPACE

Is there a way to comment out/disable entries?

share|improve this question
    
I am not aware of any commenting mechanism for the files-from file. –  jw013 Dec 14 '12 at 17:49

2 Answers 2

Do a grep -v '^#' file > /tmp/filetmp and then launch your rsync on /tmp/filetmp

Depending on your shell, you may be able to avoid the temporary file (this is valid in Bash):

rsync --files-from <(grep -v '^#' file) …

The weird-looking <( … ) syntax is what Bash calls process substitution.

share|improve this answer
3  
I added the pattern to your grep for you—I assume this is what you meant... I'm going to add in a bash trick as well, feel free to revert one or both edits if you disagree. –  derobert Dec 14 '12 at 18:32
    
Thanks to add your solution I like it !! +1 –  Dom Dec 15 '12 at 11:37

2 years on it may be a bit late, but adding oq;cq or oq#cq works to comment out lines when using the --include-from or --exclude-from options, so might work for --files-from too.

Source: rsync man page here (though interestingly not the rsync man page on my own system where this is tested and working!)

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.