Find command: how to ignore pathname

cutdirectoryfilesfindpath

I have to find some type of files in a directory and it's subdirectories and I only have to print out the filenames.
So here's the main command:
find -type f -name "*.c"

Now, how could I cut the paths from each result? (it possibily could be done with awk, but I hope, that there's an easier way to do that).

Best Answer

GNU find supports the -printf predicate, which supports the %f format specifier for outputting on the filename.

find -type f -name "*.c" -printf '%f\n'
Related Question