Craig White wrote:
On my CentOS 4.6 server, this works...
if [ -z `grep entry_chooser.js /var/log/httpd/access_log` ]
On my CentOS 5.1 server, this gives me the following error...
./test_file.scr: line 3: [: too many arguments
Can anyone explain why the difference and suggest something that makes both cases happy?
Thanks
Craig
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Not sure why 4.6 is allowing it, but your if test will be resolving to something like this:- if [ -z this line from your log file and another line and even more lines until your if test fails with too many arguments I hope you don't want me to keep typing to make the point ]
To fix it, wrap the grep instead double quotes as well as the ticks - e.g. if [ -z "`grep entry_chooser.js /var/log/httpd/access_log`" ] Then the output from the grep will be seen as one long string, not a multitude of words from your log file.
Ian