英文:
How to Search for file and path in Linux
问题
我怎么搜索文件并打印出它们的目录。
我一直在尝试
ls -R | grep "filename.txt"
但它只打印出文件名。如何修改这个命令以打印出文件的路径,或者是否有任何命令?
谢谢您。
英文:
How can i search files and print out their directory.
I have been trying
ls -R | grep "filename.txt"
however it only prints out the filename. How can i modify this command to printout the path of the file or is their any command
Thankyou
答案1
得分: 1
你可以在终端中使用“find”命令。
示例:find -name filename.txt
您可以定义一个起始搜索的目录:
示例:find /path/to/start -name filename.txt
您还可以查找匹配的模式:
示例:find -name "*.txt"
使用 / 会搜索整个文件系统,但这可能会给您的计算机带来较重的负担:
示例:find / -name filename.txt
英文:
you can use the "find" command in the terminal.
Ex: find -name filename.txt
You can define a directory to start the search:
Ex: find /path/to/start -name filename.txt
You can also find match a pattern:
Ex: find -name "*.txt"
Using a / will search the entire file system, but this can cause a heavy load on your computer:
Ex: find / -name filename.txt
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论