Updated version.
First speed of reading will differ from SSD to HDD and the buffering and caching size.
So I am assuming that you have permission to access folders ( quote "i am not able to get the result in multiple occasion", for some folders you may need privilege to access, otherwise you
may get this message "du: cannot read directory '/direc/tori/ss ': Permission denied")
Based on your
du -hsx * | sort -rh | head -10
h: print sizes in human readable format
s: --summarize you want the total size of directory,(you didn't ask for sub-directory, did you?)
x: you want to "skip directories on different file systems"
sort the result r: reverse and h: human numeric (you need h here because you use it there with du to distigush K,M,G)
head -10 : get the first top 10 of the sorted list
Is there another way beside du? yes, one of them is using ncdu (curses-based version of du)
Explain:
Examine the time (locally) BASED ON MY SYSTEM'S PERFORMANCE
GNU bash, version 5.1.4
For HDD 7200rpm that has 132G of data
Assuming the right directory:
1- time du -hsx * | sort -rh | head -10
real 0m44.978s
user 0m2.432s
sys 0m13.183s
2- time du -B 1 --max-depth=1 | sort -rh | head -10
real 0m43.823s
user 0m2.269s
sys 0m12.879s
real : elapsed time
user,and sys : CPU process time.
If you have big file (say iso file) will show up at the first du, but the second will show you only directories.
In my case without using head:
this is the sizes using your command files and folders
38G,22G,20G,11G,9.6G,6.9G,5.9G,3.2G,3.2G,2.7G,781M,590M,301M,132M,12M,6.9M,6.7M,3.6M,3.5M,276K,224K,25K,4.0K,4.0K,4.0K,512,0
When I use mine (after converting blocks to K,M,G)
123GiB, 38GiB, 22GiB, 20GiB, 11GiB, 9.6GiB, 6.9GiB, 3.2GiB, 3.2GiB, 781MiB, 590MiB, 301MiB, 132MiB, 12MiB, 6.9MiB, 6.7MiB, 3.6MiB, 3.5MiB, 276KiB, 224KiB, 100KiB, 25KiB, 512B
Files didn't show up.
I don't think I need to proof that the SSD is way faster than the HDD.
ncdu 1.15.1 with no sort
real 0m43.550s
user 0m2.742s
sys 0m13.604s
Also ncdu has ssh option for remote connection check it out.
If you are using different shell, update your question and give more information based on the answers and comments you have read.
Finally I don't think the time difference between the two commands are significant, so you can save the result to text file overnight, and sort
it later.