Check if a file is executable

后端 未结 6 833
粉色の甜心
粉色の甜心 2020-11-27 16:11

I am wondering what\'s the easiest way to check if a program is executable with bash, without executing it ? It should at least check whether the file has execute rights, a

6条回答
  •  青春惊慌失措
    2020-11-27 16:54

    Seems nobody noticed that -x operator does not differ file with directory.

    So to precisely check an executable file, you may use [[ -f SomeFile && -x SomeFile ]]

提交回复
热议问题