Shell script help

Nils Kassube kassube at gmx.net
Thu Oct 16 09:04:10 UTC 2014


Colin Law wrote:
> 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.

Actually I didn't think of malicious intent but more something like 
directory names with charcters that could be interpreted by the shell. 
Something like my music collection where directories are used for artist 
names including some names with "&".


Nils





More information about the ubuntu-users mailing list