discuss: GNU Linux Command Line Tools Summary Ready for inclusion


Previous by date: 25 Feb 2005 11:49:24 -0000 Re: GNU Linux Command Line Tools Summary Ready for inclusion, David Holroyd
Next by date: 25 Feb 2005 11:49:24 -0000 Re: GNU Linux Command Line Tools Summary Ready for inclusion, Rahul Sundaram
Previous in thread: 25 Feb 2005 11:49:24 -0000 Re: GNU Linux Command Line Tools Summary Ready for inclusion, David Holroyd
Next in thread: 25 Feb 2005 11:49:24 -0000 Re: GNU Linux Command Line Tools Summary Ready for inclusion, Rahul Sundaram

Subject: Re: GNU Linux Command Line Tools Summary Ready for inclusion
From: "Jaroslaw Fedevych (UALUG" ####@####.####
Date: 25 Feb 2005 11:49:24 -0000
Message-Id: <20050225114921.GA31988@fly.osdn.org.ua>

On Fri, Feb 25, 2005 at 11:13:14AM +0000, David Holroyd wrote:
> On Fri, Feb 25, 2005 at 10:43:18AM +1100, Gareth Anderson wrote:
> > > Section 6.2
> > > 
> > > [[
> > > tr [A-Z] [a-z] < fileName.txt > fileNameNew.txt
> > > ]]
> > > 
> > > This example won't work because the arguments of tr are not
> > > quoted.
> > 
> > Then why does it work on my Mandrake, 9.1 and 10.1 box?
> 
> Why?  Luck...
> 
>   dave@dunce:~$ echo FOO | tr [A-Z] [a-z]
>   foo
>   dave@dunce:~$ touch A
>   dave@dunce:~$ echo FOO | tr [A-Z] [a-z]
>   FOO
> 

It will work because shell performs expansion. You get another
shell, to which [ ] has other meaning, and the command works no more.

In FreeBSD man page for tr its arguments which include [ and ] are
always quoted. Why? Try 

echo foo | tr [:lower:] [:upper:]

and 

echo foo | tr "[:lower:]" "[:upper:]" 

and see it for yourself.

-- 
X windows: Warn your friends about it.


Previous by date: 25 Feb 2005 11:49:24 -0000 Re: GNU Linux Command Line Tools Summary Ready for inclusion, David Holroyd
Next by date: 25 Feb 2005 11:49:24 -0000 Re: GNU Linux Command Line Tools Summary Ready for inclusion, Rahul Sundaram
Previous in thread: 25 Feb 2005 11:49:24 -0000 Re: GNU Linux Command Line Tools Summary Ready for inclusion, David Holroyd
Next in thread: 25 Feb 2005 11:49:24 -0000 Re: GNU Linux Command Line Tools Summary Ready for inclusion, Rahul Sundaram


  ©The Linux Documentation Project, 2014. Listserver maintained by dr Serge Victor on ibiblio.org servers. See current spam statz.