Reputation: 366
Is there a way to scan a path and group and count the file extensions?
Upvotes: 2
Views: 452
Reputation: 2828
To count how many files for each extension are present in a path, you can use one of the answers of "Count files in a directory by extension" question of another site[1], e.g.:
ls | awk -F . '{print $NF}' | sort | uniq -c | awk '{print $2,$1}'
To group the files by extension you can use simply the -X
option of ls
ls -X
--sort=WORD sort by WORD instead of name: none -U, extension -X, size -S, time -t, version -v
Note:
Upvotes: 0
Reputation: 187
If I understand your question, you can use this command -
ls -ls | awk '{print $10}' | grep "\." | awk -F. '{print $2}' | sort | uniq -c
which count the extensions in the current path.
Upvotes: 1