I have used find and saved the result to file.txt file. Now I want to check files with same name sorted highest count first. e.g.:
/Volumes/1 drive/foo
/Volumes/1 drive/bar
/Volumes/1 drive/foo2
/Volumes/2 drive/foo
/Volumes/2 drive/bar2
/Volumes/3 drive/1/foo
/Volumes/3 drive/2/bar
I am running this command:
cat file.txt | awk -F '/' '{print $NR}' | uniq -c | sort
But awk output doesn't work correctly, it prints only first line:
Volumes
1 drive
foo
EDIT: The output should be:
3 foo
2 bar
1 foo2
1 bar2