如何列出一个目录下的所有可执行文件
发表于 : 2015-09-30 20:35
不跟踪软链接。
仅列文件名,不要 ls -l 那种长格式。
仅列文件名,不要 ls -l 那种长格式。
代码: 全选
ls -l | egrep "^-[^ ]*x" | awk '{for(i=9;i<=NF;i++) {printf $i" "} printf "\n"}'
代码: 全选
sudo ls -F | grep "*"
susbarbatus 写了:啧啧啧…你不懂写成一行的美啊,管道才是男人浪漫
代码: 全选
cd "$Dir"; for file in *; do; [ -f "$file" -a -x "$file" ] && echo "$file"; done
嗯,其实交互式我一直用 -F 的。只是这里还要去掉星号,有些麻烦。poloshiao 写了:試試參見代码: 全选
sudo ls -F | grep "*"
http://manpages.ubuntu.com/manpages/viv ... /ls.1.html
-F, --classify
說明
上述指令列出來的檔案名稱 後面多了一個 "*"
標示 可執行 屬性
代码: 全选
find /bin -type f -perm -111
ls -F |sed -n '/\*$/'p |sed -e 's/*$//g'
代码: 全选
man find
-executable
Matches files which are executable and directories which are searchable (in a file name reso-
lution sense). This takes into account access control lists and other permissions artefacts
which the -perm test ignores. This test makes use of the access(2) system call, and so can be
fooled by NFS servers which do UID mapping (or root-squashing), since many systems implement
access(2) in the client’s kernel and so cannot make use of the UID mapping information held on
the server. Because this test is based only on the result of the access(2) system call, there
is no guarantee that a file for which this test succeeds can actually be executed.