[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: How to handle passing filenames with spaces and wildcards into bash scripts?




On 3/1/06, Paul Howarth <paul city-fan org> wrote:
On Wed, 2006-03-01 at 16:38 -0500, Michael Wiktowy wrote:
> #!/bin/bash
> find $* -print0 | xargs -0 -I % command_to_iterate_over %

Try "$@" instead of $*

Paul.


I knew there was something obvious that I was missing.

The following:
#!/bin/bash
find "$@" -print0 | xargs -0 -I % command_to_iterate_over %

Does exactly what I needed when calling it with unquoted but properly escaped argument like:
./script /path/to/filenames\ with\ spaces* /other/path\ with\ spaces/to\ other\ filenames\ with\ spaces*

It doesn't work with quoted command-line parameters with wildcards in them but that's OK to me. I will have to experiment a bit more with that and put $@ in my mental toolbox.

Thank you kindly, Paul and Robert!

/Mike

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]