If wordcount of a command is 0 then echo XXXX else echo YYYYY
if [ `cat /tmp/foobar.txt | awk '{print $2}' | grep database | grep -v `df -k |grep /dev/dsk | awk '{print $6}'` | wc -l` != 0 ]; then echo "all devices are created on RAID10"; else echo "Some devices are created on non-RAID10"; fi
I receive this message
-bash: command substitution: line 1: syntax error near unexpected token `|'
-bash: command substitution: line 1: ` | wc -l'
Usage: grep -hblcnsviw pattern file . . .
awk: can't open !=
-bash: [: missing `]'
Some devices are created on non-RAID10
if [ `awk '{print $2}' /tmp/foobar.txt | grep database | grep -v 'df -k' |grep '/dev/dsk' | awk '{print $6}' | wc -l` -ne 0 ]; then echo "all devices are created on RAID10"; else echo "Some devices are created on non-RAID10"; fi
Too many grep-s, awk-s and cat-s - could be simplified with a single 'awk'