Bash conditionals: how to “and” expressions? (if [ ! -z $VAR && -e $VAR ])

前端 未结 5 1654
故里飘歌
故里飘歌 2021-01-29 22:04

I guess I\'m not clear on how to do \"and\" tests. I wanted to make sure an argument existed which was working well with [ -e $VAR ], but it turns out that was also

5条回答
  •  后悔当初
    2021-01-29 22:56

    I found an answer now. Thanks for your suggestions!

    for e in ./*.cutoff.txt; do
    if grep -q -E 'COX1|Cu-oxidase' $e
    then
        echo xyz >$e.match.txt
    else
        echo
    fi
    
    if grep -q -E 'AMO' $e
    then
        echo abc >$e.match.txt
    else
        echo
    fi; done
    

    Any comments on that? It seems inefficient to grep twice, but it works...

提交回复
热议问题