[Unix] Search for a particular file in Sub-directories

[How To] Search for a particular file in Sub-directories

Searching for a particular file in multiple sub-directories with a dense structure can be a nightmare had it not been for Unix. To make it further complex, lets assume you only know that a particular part of the filename.

The follwoing command finds all the files with "COUNT" in its file name withing all the sub-directories of the current working directory.

$ find . -name "*COUNT*" -print

On my box, the above command gave the following output.

./AMS/GMI_MERGED_AMS_TRADE_PP_TGT_COUNT_20110425.txt
./AMS/GMI_MERGED_AMS_TRADE_CP_TGT_COUNT_20110425.txt
./EUR/LIQ_OPERA_EUR_TRS_PP_TGT_COUNT_20120416.txt
./GLOBAL/TGT_COUNT_FILE_20120530_RFR1.txt
./GLOBAL/TGT_COUNT_PER_MAIN_BOOK_20120530_RFR1.txt
./PAC/GMI_MERGED_PAC_TRADE_PP_TGT_COUNT_20120612.txt
./PAC/GMI_MERGED_PAC_TRADE_CP_TGT_COUNT_20120612.txt
./PAC/GMI_MERGED_PAC_GLOF_STG_LOAD_TGT_COUNT_20110425.txt


My next post shows a way to search a srting in a file, in your entire directory tree.