如何只获得文件名与Linux`发现`? [英] How to only get file name with linux `find`?
本文介绍了如何只获得文件名与Linux`发现`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
./ dir1 / dir2 / file.txt
,我想得到 file.txt
解决方案在GNU
find
中,可以使用 -printf <
$ b find / dir1 -type f -printf%f \ n
I'm using find to all files in directory, so I get a list of paths. However, I need only file names. i.e. I get ./dir1/dir2/file.txt
and I want to get file.txt
解决方案 In GNU find
you can use -printf
parameter for that, e.g.:
find /dir1 -type f -printf "%f\n"
这篇关于如何只获得文件名与Linux`发现`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文