[英]how to remove everything inside directory except a list of files and directories?
[英]How to list the files inside directory and sub directories?
我有一個目錄,並且在其中有包含文本文件的子目錄,現在我想列出帶有路徑的子目錄中的所有.txt文件。 這個怎么做?
使用查找命令
find /where/to/search -name "*.txt" -type f
那只會列出以.txt結尾的文件。 使用-type f,即使名稱恰好以.txt結尾,它也不會列出目錄。
嘗試這個 :
find / -type f -name \*.txt
它將為您提供“ /”目錄中的所有.txt文件。
幾種方法:
echo directory_name/*/*.txt
可能是最有效的: echo
是內置的shell,*擴展由bash
完成。 如果您需要更多電源,請使用ls
代替echo
試試這個: tree -R | grep ".txt"
tree -R | grep ".txt"
ls -R path_of_your_directory | grep "\.txt$"
例:
ls -R /tmp | grep "\.txt$"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.