
Quero fazer uma instrução if then: Se a variável i for igual ao regex de 0 a 9 E se grep não retornar nenhum resultado, faça alguma coisa. Esta é a sintaxe correta?
if [[ $i =~ [0-9] ]] && if ! grep $i /opt/tftpboot/*; then
ou é
if [[ $i =~ [0-9] ]] && ! [[ grep $i /opt/tftpboot/* ]]; then
Responder1
Isso é:
if [[ $i =~ [0-9] ]] && ! grep $i /opt/tftpboot/*; then
Você provavelmente não precisa da saída de grep
; nesse caso, você pode fazer:
if [[ $i =~ [0-9] ]] && ! grep -q $i /opt/tftpboot/*; then