
Quiero hacer una declaración si entonces: si la variable i es igual a la expresión regular del 0 al 9 Y si grep no devuelve ningún resultado, entonces haga algo. ¿Es esta la sintaxis correcta?
if [[ $i =~ [0-9] ]] && if ! grep $i /opt/tftpboot/*; then
O es eso
if [[ $i =~ [0-9] ]] && ! [[ grep $i /opt/tftpboot/* ]]; then
Respuesta1
Es:
if [[ $i =~ [0-9] ]] && ! grep $i /opt/tftpboot/*; then
Probablemente no necesites el resultado de grep
, en cuyo caso puedes hacer:
if [[ $i =~ [0-9] ]] && ! grep -q $i /opt/tftpboot/*; then