Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 12-11-2015, 05:01 AM   #1
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 296
Blog Entries: 2

Rep: Reputation: 16
Talking rsync: How to use -prune-empty-dirs with the options: "+ */", "+ *.c" AND "- *"?

I was reading the rsync manual file, and on line 3155-3157 I read
o The combination of "+ */", "+ *.c", and "- *" would include all
directories and C source files but nothing else (see also the
--prune-empty-dirs option)
This really looks both interesting and practical.

So to try it out I first make a complex directory structure, with some *.c, *.txt and *.json files:
mkdir -p source/{.cache,.codeblocks,.config,.gconf,.chrome/{"Crash Reports",googleCu.default/{datareporting,healthreport/{crash,freeze,delay},analytics/{yourRecentClicks,yourFinancialPasswords,history/{mortage,purchases,socioEconomicClass,gender,race,ethnicity,sxlPreference,age,location,politicalParty},dir1},extensions},igoogle},.gconf}
touch source/{.cache/rememberUrPrivRights.c,.codeblocks/rememberUrPrivRights.c,.config/rememberUrPrivRights.c,.gconf/rememberUrPrivRights.c,.chrome/{"Crash Reports"/rememberUrPrivRights.c,googleCu.default/rememberUrPrivRights.c,igoogle/rememberUrPrivRights.c},.gconf/rememberUrPrivRights.c}
touch source/{.cache/new.txt,.codeblocks/new.txt,.config/new.txt,.gconf/new.txt,.chrome/{"Crash Reports"/new.txt,googleCu.default/{datareporting/new.txt,healthreport/new.txt,analytics/{yourRecentClicks/new.txt,yourFinancialPasswords/new.txt,history/{mortage/new.txt,purchases/new.txt,socioEconomicClass/new.txt,gender/new.txt,race/new.txt,ethnicity/new.txt,sxlPreference/new.txt,age/new.txt,location/new.txt,politicalParty/new.txt},dir1},extensions},igoogle},.gconf/new.txt}
touch source/{.cache/new.json,.codeblocks/new.json,.config/new.json,.gconf/new.json,.chrome/{"Crash Reports"/new.json,googleCu.default/{datareporting/new.json,healthreport/new.json,analytics/{yourRecentClicks/new.json,yourFinancialPasswords/new.json,history/{mortage/new.json,purchases/new.json,socioEconomicClass/new.json,gender/new.json,race/new.json,ethnicity/new.json,sxlPreference/new.json,age/new.json,location/new.json,politicalParty/new.json},dir1},extensions},igoogle},.gconf/new.json}
Note how above NONE of the folders whose functions are unconstitutional have c files.

So with my source folder's complex directory structure set up, I then try the rsync --prune-empty-dirs command with the three "+ */", "+ *.c", and "- *" combinations:
$ rsync -Savi -Eu --prune-empty-dirs "+ */" "+ *.c" "- *" source destination
rsync: - *: unknown option
rsync error: syntax or usage error (code 1) at main.c(1572) [client=3.1.0]
I ixquicked(internet search) this issue, and I could\'t find "rsync --prune" tutorials that utilized the +/- options with multiple arguments.

Does anyone have any example of how to use -prune-empty-dirs with the three "+ */", "+ *.c", and "- *" combinations?

Last edited by andrew.comly; 12-11-2015 at 10:01 PM. Reason: title too specific
Old 12-11-2015, 06:49 AM   #2
Registered: Nov 2015
Posts: 104

Rep: Reputation: 38
Try putting a -f in front of each filter rule, so that rsync knows that that is what they are. Otherwise it sees the '-' and assumes its a normal option.

rsync -Savi -Eu --prune-empty-dirs -f "+ */" -f "+ *.c" -f "- *" source destination
That way you get the following output.
building file list ... done
created directory destination
cd+++++++++ source/
cd+++++++++ source/.cache/
>f+++++++++ source/.cache/rememberUrPrivRights.c
cd+++++++++ source/.chrome/
cd+++++++++ source/.chrome/Crash Reports/
>f+++++++++ source/.chrome/Crash Reports/rememberUrPrivRights.c
cd+++++++++ source/.chrome/googleCu.default/
>f+++++++++ source/.chrome/googleCu.default/rememberUrPrivRights.c
cd+++++++++ source/.chrome/igoogle/
>f+++++++++ source/.chrome/igoogle/rememberUrPrivRights.c
cd+++++++++ source/.codeblocks/
>f+++++++++ source/.codeblocks/rememberUrPrivRights.c
cd+++++++++ source/.config/
>f+++++++++ source/.config/rememberUrPrivRights.c
cd+++++++++ source/.gconf/
>f+++++++++ source/.gconf/rememberUrPrivRights.c

sent 1,394 bytes received 210 bytes 3,208.00 bytes/sec
total size is 0 speedup is 0.00
1 members found this post helpful.
Old 12-14-2015, 06:19 AM   #3
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 296

Original Poster
Blog Entries: 2

Rep: Reputation: 16
Talking Thanks!!

Originally Posted by fmattheus View Post
Try putting a -f in front of each filter rule,
Thanks a lot for filling me in, man files can sometimes lack examples.



bash, directory, exclude, prune, rsync

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
[SOLVED] X: "loading extension glx" "no screens found" "fatal server error" (w/ nvidia driver) Geremia Slackware 7 12-29-2014 11:00 AM
[SOLVED] "net rpc" "failed to connect to ipc$ share on" or "unable to find a suitable server" larieu Linux - General 0 11-09-2014 12:45 AM
What are the options "Nosuid" "mode" "size" in /etc/fstab? does not help pstein Linux - Newbie 1 11-16-2012 12:58 AM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:05 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration