如何列出一个目录下的所有可执行文件
- 自由建客
- 帖子: 13468
- 注册时间: 2008-07-30 23:21
- 系统: Debian stable AMD64
如何列出一个目录下的所有可执行文件
不跟踪软链接。
仅列文件名,不要 ls -l 那种长格式。
仅列文件名,不要 ls -l 那种长格式。
- susbarbatus
- 帖子: 2966
- 注册时间: 2010-04-10 16:14
- 系统: Arch Linux
Re: 如何列出一个目录下的所有可执行文件
笨办法:
代码: 全选
ls -l | egrep "^-[^ ]*x" | awk '{for(i=9;i<=NF;i++) {printf $i" "} printf "\n"}'
上次由 susbarbatus 在 2015-12-14 13:55,总共编辑 1 次。
沉迷将棋中……
- 自由建客
- 帖子: 13468
- 注册时间: 2008-07-30 23:21
- 系统: Debian stable AMD64
-
- 论坛版主
- 帖子: 18279
- 注册时间: 2009-08-04 16:33
Re: 如何列出一个目录下的所有可执行文件
試試
參見
http://manpages.ubuntu.com/manpages/viv ... /ls.1.html
-F, --classify
說明
上述指令列出來的檔案名稱 後面多了一個 "*"
標示 可執行 屬性
代码: 全选
sudo ls -F | grep "*"
http://manpages.ubuntu.com/manpages/viv ... /ls.1.html
-F, --classify
說明
上述指令列出來的檔案名稱 後面多了一個 "*"
標示 可執行 屬性
- susbarbatus
- 帖子: 2966
- 注册时间: 2010-04-10 16:14
- 系统: Arch Linux
- 自由建客
- 帖子: 13468
- 注册时间: 2008-07-30 23:21
- 系统: Debian stable AMD64
Re: 如何列出一个目录下的所有可执行文件
susbarbatus 写了:啧啧啧…你不懂写成一行的美啊,管道才是男人浪漫
代码: 全选
cd "$Dir"; for file in *; do; [ -f "$file" -a -x "$file" ] && echo "$file"; done
- 自由建客
- 帖子: 13468
- 注册时间: 2008-07-30 23:21
- 系统: Debian stable AMD64
Re: 如何列出一个目录下的所有可执行文件
嗯,其实交互式我一直用 -F 的。只是这里还要去掉星号,有些麻烦。poloshiao 写了:試試參見代码: 全选
sudo ls -F | grep "*"
http://manpages.ubuntu.com/manpages/viv ... /ls.1.html
-F, --classify
說明
上述指令列出來的檔案名稱 後面多了一個 "*"
標示 可執行 屬性
- YeLee
- 论坛版主
- 帖子: 26406
- 注册时间: 2008-08-13 8:48
- 系统: Fundu i64
- 来自: 东海硇州,一双管钥。
- 联系:
Re: 如何列出一个目录下的所有可执行文件
代码: 全选
find /bin -type f -perm -111
ls -F |sed -n '/\*$/'p |sed -e 's/*$//g'
◎当我站在道德的高度上俯视别人的时候,发现自己是多么渺小。
♥执着但不偏激,反对而不排斥,坚决捍卫矛盾体的存在方式。
★★★天气预报★★★
fcitx-yatable一个可以使用的码表输入法
[教程]几个实例攻克软件编译难关
Gentoo Development Guide
字体相关
♥执着但不偏激,反对而不排斥,坚决捍卫矛盾体的存在方式。
★★★天气预报★★★
fcitx-yatable一个可以使用的码表输入法
[教程]几个实例攻克软件编译难关
Gentoo Development Guide
字体相关
-
- 帖子: 53
- 注册时间: 2010-12-09 23:54
Re: 如何列出一个目录下的所有可执行文件
find / -type f -executable
代码: 全选
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.