Find unique values from find

cshfind

I want to find unique files inside a directory, which also have sub directories.

There are specific types of files, say .lib files.

There are same .lib file inside different sub directoris. I need to find the list of .lib files inside my home directory, but only unique names. Are there any method to do so ?

Currently I am using

find -name "*.lib" > lib_file_list

But it gives duplicate results as some of the .lib files are in multiple sub directories. I am using CSH.

Best Answer

With GNU tools:

find . -name '*.lib' -print0 | awk -v RS='\0' -F/ '! seen[$NF]++'
Related Question