This is my first post on StackOverflow, so please be gentle.
What I am trying to do is to sort the output of find by size (from greatest to smallest).
I have a file.txt which contains:
file1
file2
file3
file4
file5
file6
My code looks like this:
for x in $(cat file.txt)
do
find -name $x -printf '%s %p\n'| sort -rn
done
But instead the output is not sorted.
The output is the path of the files (which is great) and their sizes in the same order as in the file.
For example:
128 /dir1/file1
8 /dir2/file2
0 file3
4 file4
...
and so on