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

🌫️ Project Title: "Fog Buster – AI-Powered Visibility Enhancement System"

🔍 Project Vision: To design a device that allows vehicles (cars, trucks) and aircraft (planes, helicopters, drones) to see clearly during f...