Thursday, December 21, 2023

How to i see list of only file and sort by type and see count of each type of files

find . -type f -printf "%f\n" | awk -F. '{print $NF}' | sort | uniq -c

  • find . -type f -printf "%f\n": This finds all files (-type f) in the current directory (.) and prints only their names (%f) followed by a newline.
  • awk -F. '{print $NF}': This uses awk to extract the file extensions by splitting each filename at the dot (.) and printing the last field ($NF).
  • sort: This sorts the file extensions alphabetically.
  • uniq -c: This counts the occurrences of each unique file extension.

This command will output a list showing the count of each file type in the current directory. Adjust the starting directory in the find command (. in this example) if you want to search in a different directory.

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

Enhancing Unix Proficiency: A Deeper Look at the 'Sleep' Command and Signals

Hashtags: #Unix #SleepCommand #Signals #UnixTutorial #ProcessManagement In the world of Unix commands, there are often tools that, at first ...