Reputation: 30615
Using Bash how would I get all file names (not paths) of files containing ".cpp", given a root folder to recursively-check?
Upvotes: 1
Views: 620
Reputation: 11098
You can use for that purpose -printf
option of find
command with the following parameter:
%f File's name with any leading directories removed (only the last element).
so the full command may look like this:
find / -type f -name "*.cpp" -printf "%f\n"
Upvotes: 1
Reputation: 120644
Just use find
:
find /root/folder/to/check -name '*.cpp' -printf "%P\n"
Upvotes: 2