Shell script help
Nils Kassube
kassube at gmx.net
Thu Oct 16 07:01:44 UTC 2014
Colin Law wrote:
> To clarify, a script called, for example, using something like
> myscript "the path*" note the trailing *
>
> and in myscript something like
>
> for f in /a/b/"$1"/*.txt
> where this is to be interpreted as
> for f in /a/b/the\ path*/*.txt
You could set IFS to "\n\t" [1] to eliminate the problem of spaces in
the filename an then omit the quotes around "$1" - something like this:
IFS="$(printf '\n\t')"
for f in /a/b/$1/*.txt
But I'm not sure if that would be safe with arbitrary directory names.
Nils
[1] <http://www.dwheeler.com/essays/filenames-in-shell.html#ifs>
More information about the ubuntu-users
mailing list