I want to detect if the 1st bash input parameter is "debug"(string).
I write script like this:
#! /usr/bin/env bash
if [ "$#" -eq "1" && "$1" -eq "debug" ]; then
echo "hello debug"
fi
Error message:
line 3: [: missing `]'
I don't know why, please help.
$#here; you can ignore additional arguments if present, and if$#is 0, then"$1" = debugwill be false since$1expands to the empty string.