Shell script help
Colin Law
clanlaw at gmail.com
Thu Oct 16 08:11:57 UTC 2014
On 16 October 2014 08:01, Nils Kassube <kassube at gmx.net> wrote:
> 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.
Excellent idea. It is only for private use for a particular purpose,
and in fact will generally be called from another script, so no
worries about the script being used with malicious intent.
Thanks
Colin
More information about the ubuntu-users
mailing list