Stop trying to use the [
command to execute another command.
if ... && grep ...
Example:
if [ -f "$Log_dir/output.rej" ] &&
grep -Hne "fails to validate" $Log_dir/output.rej >/dev/null
then
...
fi
Question
I have 1 script starting with #!/bin/ksh
Here is the code piece that create line 42: [: too many arguments
if [ -f "$Log_dir/output.rej" ] &&
[ grep -Hne "fails to validate" $Log_dir/output.rej >/dev/null ]
it expand to (set -xv)
+ '[' -f /export/home/xxxx/xsdlog/output.rej ']'
+ '[' grep -Hne 'fails to validate' /export/home/xxxx/xsdlog/output.rej ']'
TEST_VALIDATE.sh: line 42: [: too many arguments
I tried
if [ -f $Log_dir/output.rej ] &&
[ grep -Hne "fails to validate" $Log_dir/output.rej >/dev/null ]
without quotes("). The results same.
How do I fix this error?
No correct solution
OTHER TIPS
Stop trying to use the [
command to execute another command.
if ... && grep ...
Example:
if [ -f "$Log_dir/output.rej" ] &&
grep -Hne "fails to validate" $Log_dir/output.rej >/dev/null
then
...
fi