![](/img/trans.png)
[英]How to find all the files that use a particular header in a specified directory on Linux?
[英]How to use find in linux to output all files in current directory which match multiple criteria in a single line
嘗試在 linux 到 output 中使用 1 行命令輸出當前目錄中符合此條件的所有文件:
我知道在搜索 1 個條件時如何使用 find 但無法使其與多個條件一起使用,尤其是在一行中。
您可以將 glob 表達式與查找一起使用。 事實上,您正在尋找具有零個或多個字符的文件名,然后是“b”,然后是另一個零個或多個字符序列,然后是“a”,然后是擴展名“.csv”,即:
find . -name '*b*a.csv'
你甚至不需要find
,假設你想遍歷文件。 然后你可以將文件名保存在 bash 數組中,如下所示:
files=(*b*a.csv)
for f in ${files[@]}; do
echo "$f" # place holder for whatever command you want to run
done
但是,如果您真的只想使用find
,@Mureinik 的回答就足夠了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.