![](/img/trans.png)
[英]How to find multiple files, check for duplicates and replace with bash,sed script
[英]Bash Script: Check if multiple files are executable and output them?
你可以制作一個遍歷文件夾(例如主目錄)並打印所有可執行文件的名稱的腳本嗎?
你知道find
命令有一個-executable
開關嗎?
如果您想查看所有子目錄中的所有可執行文件,您可以這樣做:
find ./ -type f -executable
如果您想查看所有可執行文件,但只是在您的目錄中,您可以這樣做:
find ./ -maxdepth 1 -type f -executable
我可以。
#!/bin/bash
for d in "$@"
do [[ -d "$d" ]] || { printf '\n"%s" not a directory\n' "$d"; continue; }
for f in "$d"/* "$d"/.*; do [[ -f "$f" && -x "$f" ]] && ls -l "$f"; done
done
但是按照 Dominique 的建議使用find
。
為什么要重新發明輪子?
盡管如此,仍有很多事情可能有用。
如果您有任何問題,請告訴我。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.