is there a command to list what type of files are in a directory and the size?
for example, .jpg 1GB, .png 2GB, .avi 3GB etc. , thanks
is there a command to list what type of files are in a directory and the size?
for example, .jpg 1GB, .png 2GB, .avi 3GB etc. , thanks
You could use
file
to determine the actual file type (MIME type) based on its content instead of the file extension, and you can use pure Bash to aggregate the size sum per type.Have a look at this example:
And to verify the results, the sum of all values above is exactly equal to what
du
reports:Here's the used command-line from above commented and formatted in a more readable way as a script:
A method would be:
Result from my Desktop: