if中的多个条件

时间:2013-09-30 11:26:02

标签: linux shell

    [ -r "$df" ] && {   
        tail -1 $df | grep "$was_fallback" > /dev/null     
        [ $? -ne 0 ] && { continue; }    

这是更大代码的一部分。我正在阅读老年人写的一些旧代码。然后我找到了这段代码。 我知道[]是'if'条件。但是这个用于什么?

1 个答案:

答案 0 :(得分:3)

I know that [ ] is for 'if' condition

没有。这不是 if 条件。 [是测试命令。更多关于它的信息:

<强> What is the difference between test, [ and [[ ?

what is this {} used for?

它叫做 command grouping 。从GNU手册:

{}

    { list; }

    Placing a list of commands between curly braces causes the list to be
    executed in the current shell context. No subshell is created. 
    The semicolon (or newline) following list is required.