Search for executable files using find command

前端 未结 10 871
既然无缘
既然无缘 2020-12-07 11:21

What type of parameter/flag can I use with the Unix find command so that I search executables?

10条回答
  •  盖世英雄少女心
    2020-12-07 11:55

    This worked for me & thought of sharing...

    find ./ -type f -name "*" -not -name "*.o" -exec sh -c '
        case "$(head -n 1 "$1")" in
          ?ELF*) exit 0;;
          MZ*) exit 0;;
          #!*/ocamlrun*)exit0;;
        esac
    exit 1
    ' sh {} \; -print
    

提交回复
热议问题