tharani dharan
tharani dharan

Reputation: 425

how to get a list of particular file type in a folder and subfolders in linux and sort by file size

how to get a list of particular file type in a folder and sub folders in Linux and sort by file size

This is what i tried

find . -type f -name "*xml" | sort -r -n 

It did not sort the files based on size

Upvotes: 0

Views: 121

Answers (1)

salparadise
salparadise

Reputation: 5805

you can print the top 50 this way:

find . -type f -iname "*xml" -exec du {} + | sort -rn | head -n50

obviously drop the head if you want all of them

find . -iname "*txt" -exec du {} + | sort -rn

Upvotes: 1

Related Questions