Linux How to print all the files with the same prefix after searching for them?
Posted
by
Alyx
on Stack Overflow
See other posts from Stack Overflow
or by Alyx
Published on 2012-10-14T21:28:30Z
Indexed on
2012/10/14
21:36 UTC
Read the original article
Hit count: 159
I need to search through a directory which contains many sub directories, each which contain files. The files read as follows question1234_01, where 1234 are random digits and the suffix _01 is the number of messages that contain the prefix, meaning they are apart of the same continuing thread.
find . -name 'quest*' | cut -d_ -f1 | awk '{print $1}' | uniq -c | sort -n
example output:
1 quest1234
10 quest1523
This searches for all the files then sorts them in order.
What I want to do is print all the files which end up having the most occurrences, in my example the one with 10 matches.
So it should only output quest1523_01 - 11
© Stack Overflow or respective owner