简体   繁体   中英

How to find files without a directory path in Linux

I have a directory: test/test1/file1.sh test/file2.sh

What i need as a output: file1.sh file2.sh

I need to hide the dir.path at the output

It depends on your criteria which files should be included in the output, but if you want to print the names of all *.sh files under test/ , you can do:

$ find <path_to_test_folder> '*.sh' -printf %f\\n

(If you're running it from the root folder of the search, you can drop the <...> part.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM