Why do I get these errors:
-bash: [: missing `]'
grep: ): No such file or directory
grep: ]: No such file or directory
when I run this in sh or bash:
if [ \( lsusb -t | grep -q 'qmi_wwan' \) ]; then
    echo 'yes'
else
    echo 'no'
fi
Why do I get these errors:
-bash: [: missing `]'
grep: ): No such file or directory
grep: ]: No such file or directory
when I run this in sh or bash:
if [ \( lsusb -t | grep -q 'qmi_wwan' \) ]; then
    echo 'yes'
else
    echo 'no'
fi
 
    
    If you want to check the exit code of the grep command, use it instead of the [ command:
if lsusb -t | grep -q 'qmi_wwan'
then
  echo "Yes"
fi
