当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 9 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : 如何列出一个目录下的所有可执行文件
帖子发表于 : 2015-09-30 20:35 
头像

注册: 2008-07-30 23:21
帖子: 13427
地址: freebuilder@yeah.net
系统: Debian stable AMD64
送出感谢: 38
接收感谢: 127
不跟踪软链接。
仅列文件名,不要 ls -l 那种长格式。


_________________
(2015-11-16 更新)适合 WM 的截图脚本
(2015-08-24 更新)Debian、Ubuntu 源列表说明
(2013-02-01 首发)文字如何绘出
▷▷ 【更 多 在 此】 ◁◁
箪食瓢饮随遇安,不求栋梁求参天。
【初韵】一门牛逼的编程语言。


页首
 用户资料  
 
2 楼 
 文章标题 : Re: 如何列出一个目录下的所有可执行文件
帖子发表于 : 2015-09-30 20:55 
头像

注册: 2010-04-10 16:14
帖子: 2903
系统: Arch Linux
送出感谢: 8
接收感谢: 69
笨办法:
代码:
ls -l | egrep "^-[^ ]*x" | awk '{for(i=9;i<=NF;i++) {printf $i" "} printf "\n"}'


_________________
dz,U,EIS. cies.
dz-cies@github
小香猪杀手@cc98.org


最后由 susbarbatus 编辑于 2015-12-14 13:55,总共编辑了 1 次

页首
 用户资料  
 
3 楼 
 文章标题 : Re: 如何列出一个目录下的所有可执行文件
帖子发表于 : 2015-09-30 21:55 
头像

注册: 2008-07-30 23:21
帖子: 13427
地址: freebuilder@yeah.net
系统: Debian stable AMD64
送出感谢: 38
接收感谢: 127
susbarbatus 写道:
笨办法:
代码:
ls -l | egrep "^-[^ ].*x" | awk '{for(i=9;i<=NF;i++) {printf $i" "} printf "\n"}'

:em20
还不如这样呢
代码:
   cd "$Dir"
   for file in *
   do
      [ -f "$file" -a -x "$file" ] && echo "$file"
   done


_________________
(2015-11-16 更新)适合 WM 的截图脚本
(2015-08-24 更新)Debian、Ubuntu 源列表说明
(2013-02-01 首发)文字如何绘出
▷▷ 【更 多 在 此】 ◁◁
箪食瓢饮随遇安,不求栋梁求参天。
【初韵】一门牛逼的编程语言。


页首
 用户资料  
 
4 楼 
 文章标题 : Re: 如何列出一个目录下的所有可执行文件
帖子发表于 : 2015-10-01 6:20 

注册: 2009-08-04 16:33
帖子: 16882
送出感谢: 21
接收感谢: 1825
試試
代码:
sudo ls -F | grep "*"


參見
http://manpages.ubuntu.com/manpages/viv ... /ls.1.html
-F, --classify
說明
上述指令列出來的檔案名稱 後面多了一個 "*"
標示 可執行 屬性


页首
 用户资料  
 
5 楼 
 文章标题 : Re: 如何列出一个目录下的所有可执行文件
帖子发表于 : 2015-10-01 10:20 
头像

注册: 2010-04-10 16:14
帖子: 2903
系统: Arch Linux
送出感谢: 8
接收感谢: 69
自由建客 写道:
susbarbatus 写道:
笨办法:
代码:
ls -l | egrep "^-[^ ].*x" | awk '{for(i=9;i<=NF;i++) {printf $i" "} printf "\n"}'

:em20
还不如这样呢
代码:
   cd "$Dir"
   for file in *
   do
      [ -f "$file" -a -x "$file" ] && echo "$file"
   done

啧啧啧…你不懂写成一行的美啊,管道才是男人浪漫 :Shame


_________________
dz,U,EIS. cies.
dz-cies@github
小香猪杀手@cc98.org


页首
 用户资料  
 
6 楼 
 文章标题 : Re: 如何列出一个目录下的所有可执行文件
帖子发表于 : 2015-10-01 18:33 
头像

注册: 2008-07-30 23:21
帖子: 13427
地址: freebuilder@yeah.net
系统: Debian stable AMD64
送出感谢: 38
接收感谢: 127
susbarbatus 写道:
啧啧啧…你不懂写成一行的美啊,管道才是男人浪漫 :Shame

代码:
cd "$Dir"; for file in *; do; [ -f "$file" -a -x "$file" ] && echo "$file"; done


_________________
(2015-11-16 更新)适合 WM 的截图脚本
(2015-08-24 更新)Debian、Ubuntu 源列表说明
(2013-02-01 首发)文字如何绘出
▷▷ 【更 多 在 此】 ◁◁
箪食瓢饮随遇安,不求栋梁求参天。
【初韵】一门牛逼的编程语言。


页首
 用户资料  
 
7 楼 
 文章标题 : Re: 如何列出一个目录下的所有可执行文件
帖子发表于 : 2015-10-01 18:35 
头像

注册: 2008-07-30 23:21
帖子: 13427
地址: freebuilder@yeah.net
系统: Debian stable AMD64
送出感谢: 38
接收感谢: 127
poloshiao 写道:
試試
代码:
sudo ls -F | grep "*"


參見
http://manpages.ubuntu.com/manpages/viv ... /ls.1.html
-F, --classify
說明
上述指令列出來的檔案名稱 後面多了一個 "*"
標示 可執行 屬性

嗯,其实交互式我一直用 -F 的。只是这里还要去掉星号,有些麻烦。


_________________
(2015-11-16 更新)适合 WM 的截图脚本
(2015-08-24 更新)Debian、Ubuntu 源列表说明
(2013-02-01 首发)文字如何绘出
▷▷ 【更 多 在 此】 ◁◁
箪食瓢饮随遇安,不求栋梁求参天。
【初韵】一门牛逼的编程语言。


页首
 用户资料  
 
8 楼 
 文章标题 : Re: 如何列出一个目录下的所有可执行文件
帖子发表于 : 2015-10-04 10:06 
头像

注册: 2008-08-13 8:48
帖子: 26391
地址: 东海硇州,一双管钥。
系统: Fundu i64
送出感谢: 50
接收感谢: 344
代码:
find /bin -type f -perm -111
ls -F |sed -n '/\*$/'p |sed -e 's/*$//g'

:Noting


_________________
◎当我站在道德的高度上俯视别人的时候,发现自己是多么渺小。
♥执着但不偏激,反对而不排斥,坚决捍卫矛盾体的存在方式。
★★★天气预报★★★
fcitx-yatable一个可以使用的码表输入法
[教程]几个实例攻克软件编译难关
Gentoo Development Guide
字体相关


页首
 用户资料  
 
9 楼 
 文章标题 : Re: 如何列出一个目录下的所有可执行文件
帖子发表于 : 2015-12-08 22:05 

注册: 2010-12-09 23:54
帖子: 51
送出感谢: 0 次
接收感谢: 0 次
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.


_________________
http://firxiao.com


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 9 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 0 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译