Test multiple file conditions in one swoop (BASH)?

前端 未结 6 1491
滥情空心
滥情空心 2020-12-13 00:22

Often when writing for the bash shell, one needs to test if a file (or Directory) exists (or doesn\'t exist) and take appropriate action. Most common amongst these test are

6条回答
  •  执笔经年
    2020-12-13 00:55

    This seems to work (notice the double brackets):

    #!/bin/bash
    
    if [[ -fwd "/Library/Application Support" ]]
    then
        echo 'YES SIR -f -w -d are fine'
    else
        echo 'no -f or -w or -d for you'
    fi
    

提交回复
热议问题