Proč mám tyto chyby:
-bash: [: missing `]'
grep: ): No such file or directory
grep: ]: No such file or directory
když jsem spustit tento v sh
nebo bash
:
if [ \( lsusb -t | grep -q 'qmi_wwan' \) ]; then
echo 'yes'
else
echo 'no'
fi
Proč mám tyto chyby:
-bash: [: missing `]'
grep: ): No such file or directory
grep: ]: No such file or directory
když jsem spustit tento v sh
nebo bash
:
if [ \( lsusb -t | grep -q 'qmi_wwan' \) ]; then
echo 'yes'
else
echo 'no'
fi
Pokud chcete zkontrolovat ukončovací kód grep
příkaz, použijte ji namísto na [
příkaz:
if lsusb -t | grep -q 'qmi_wwan'
then
echo "Yes"
fi
[
?" Můžete použít !
, ||
a &&
pro ne/nebo/i s dalšími příkazy, včetně [
[
před a funguje to v pohodě, ale chtěl jsem zjistit, proč to nefungovalo s [
. [
s text z příkazu a jeho argumenty.