linux - BASH - 计算可执行文件的数量

标签 linux bash shell unix scripting

我试图在一个文件夹中找到可执行文件及其总数,它显示但总数不是这是我下面的代码,如果我犯了错误,有人可以帮助我吗,我只是一个试图学习一些的新手bash 脚本希望这是正确的方法,谢谢

#!/bin/bash
To="home/magie/d2"
cd "$To"
find . -type f -perm 755

if 
   find . -type f -perm 755
then
 echo | echo wc -l
fi

最佳答案

如果你想找到所有的可执行文件,那么使用这个命令:

find home/magie/d2 -type f -perm -u+rx | wc -l

find home/magie/d2 -type f -perm +111 | wc -l

这里的所有答案都是查找权限为 755 的文件,但请记住,即使是 744 或 700 也是用户的可执行文件。

关于linux - BASH - 计算可执行文件的数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8932769/

相关文章:

linux - 在 Linux 中查找并替换为参数

linux - 从脚本以非 root 身份运行程序

Bash:关闭出现权限错误的闪烁符号链接(symbolic link)(Amazon EC2)

python - taskwarrior "task del"没有确认对话框

linux - 我想删除linux中的所有文件和目录

c - 库函数返回的变量的内存分配位置

linux - 无法通过 jenkins 打开 Chrome 浏览器 --- 未知错误 : Chrome failed to start: crashed

bash - 将变量从 shell 脚本传递到 GNU screen

bash - 如何使 bash 命令定期运行?

linux - 从文件名中删除某些字符