On Sunday 18 October 2009 07:01:07 am Per Jessen wrote:
David C. Rankin wrote:
On Saturday 17 October 2009 02:53:58 am Per Jessen wrote:
David C. Rankin wrote:
I was pecking around on a script for rsync that would take the same type of file and path information with wildcards and hit upon a really cool way to handle the input without having to quote the names with wildcards to prevent expansion.
Personally, I would probably have used a filelist as input. In particular with rsync where it's difficult to use xargs.
/Per
Per,
You got an example of a filelist I can steal? I'm always looking for better ways to do things.
Hi David
Maybe the filelist doesn't really apply here - I have to admit not having studied your script in greater detail, but when I don't want wildcards expanded on the command line, I just escape them (\* etc), so perhaps I don't really recognize the problem you are solving.
Then with the double loop, I cut all my typing down to
2box /first/path /next/setof/fil* /etc/X11/x*
I think I would done something like this:
rsync -av /first/path /next/setof/fil\* /etc/X11/x\* <destination>
If it needs to be wrapped in a script:
rsync -av $@ <destination>
The filelist option is really when you want to make sure you can specify _any_ number of files.
Well that is exactly what this snippet does. That was the beauty of it. In the past, as you say, you can always escape or quote wildcards to prevent expansion. That wasn't the point. The point was this two loop snippet allows you to handle all of the native wildcards and file globbing WITHOUT having to escape or quote. That allowed the flexibility I was looking for to be able to use the native bash command line as you would with ls or any of the other bash builtins. That makes it idiot proof for users or anyone that might make use of it later because it works like everything else bash already provides -- no special tricks required. I have tried a number of ways in the past and this just happened as sort of an accident. I thought it was helpful so I posted it. Also, since rsync wildcards require "double wildcards" (i.e. rsync ~/.bash**) this expansion in the second loop also took care of that problem. So it was the killing 2 birds with one stone combination that made it noteworthy to me. If your ever stuck with the criteria of taking input containing wildcards without escapes or quotes, that is where this combo will help :) -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org