すべての実行可能ファイルを/ binから見つける必要があります。どのように使用するのですか?カレントディレクトリ内の実行可能ファイルを見つけ出し、その拡張子を調べる方法は?
find . -executable
ファイルがスクリプトかどうか(sh、pl、bashなど)を確認する方法はありますか。
すべての実行可能ファイルを/ binから見つける必要があります。どのように使用するのですか?カレントディレクトリ内の実行可能ファイルを見つけ出し、その拡張子を調べる方法は?
find . -executable
ファイルがスクリプトかどうか(sh、pl、bashなど)を確認する方法はありますか。
#!/bin/bash
for file in `find /bin` ; do
if [ -x $file ] ; then
file $file
fi
done
とさらに良い。これは、すべてのスクリプトが
find . -type f -executable | xargs file -i | grep x-shellscript | cut -d":" -f1
シェル見つけるために...私のため
find ./ -type f -name "*" -exec sh -c '
case "$(head -n 1 "$1")" in
?ELF*) exit 0;;
MZ*) exit 0;;
#!*/ocamlrun*)exit0;;
esac
exit 1
' sh {} \; -print
find /bin/ -executable
は、すべての実行可能ファイルを/bin/
ディレクトリから返します。
フィルタ拡張には、-name
フラグが使用できます。たとえば、find /bin/ -executable -name "*.sh"
はsh
-scriptsを返します。
UPD:ファイルがバイナリファイルではないと拡張子を持っていない場合
、それはshabangからの型を考え出しすることが可能です。
たとえば、find ~/bin/ -executable | xargs grep --files-with-matches '#!/bin/bash'
は、#!/bin/bash
を含むディレクトリからファイルを返します。
を行うにはすべての実行可能ファイルを見つけるには
find . -type f -executable | xargs file -i | grep x-exec | cut -d":" -f1
は
find . -type f -executable | xargs file -i | grep x-sharedlib | cut -d":" -f1
を共有&考えを働いた
find /bin -type f -perm +111 -print0 | xargs -0 file
は、サブディレクトリを取り除くためにあなたのfindコマンドに '-type F'を追加するすべての共有ライブラリを検索します。 –
実行可能ではない/ binにファイルがありますか? – uzsolt