On Fri, 2008-05-16 at 17:03 +0930, Ian Blackwell wrote: > Craig White wrote: > > That works fine one CentOS 5 (double quotes and backtics) but not on > > CentOS 4.6 > > > > Thanks...I guess it's good enough for now. > > > > Craig > > > > _______________________________________________ > > CentOS mailing list > > CentOS at centos.org > > http://lists.centos.org/mailman/listinfo/centos > > > > > I can only imagine it is "working" in 4.6 because the result of "grep > entry_chooser.js /var/log/httpd/access_log" is either empty or 1 > "word". The test syntax [ -z xxx ] would report the "too many > arguments" error whenever the grep returned more than one word. You can > test this at your command line by typing in:- > [ -z one ] > and > [ -z one two three four five ] > > The first will return "false" but you'll just see another bash prompt, > the second will report the "too many arguments" error. This is > certainly the case for me using RHEL4.6, so I would imagine CentOS4.6 > should be the same. You can also see it explained by these commands and > results:- > [irb at zaphod ~]$ [ -z ] > [irb at zaphod ~]$ echo $? > 0 > [irb at zaphod ~]$ [ -z one ] > [irb at zaphod ~]$ echo $? > 1 > [irb at zaphod ~]$[ -z one two three four ] > -bash: [: too many arguments > [irb at zaphod ~]$ echo $? > 2 > [irb at zaphod ~]$ > > I hope this helps you understand why it is "working" on one machine but > not another. > > Ian > > PS: I always prefer $(cmd) to backtics for readability. e.g. > > if [ -z "$(grep entry_chooser.js /var/log/httpd/access_log)" ] > > PPS: grep -q works for me on RHEL4.6 and CentOS5.1 ---- makes a lot of sense - thanks Craig