Sunday, May 5, 2024
Homepage · ls
 Popular · Latest · Hot · Upcoming
20
rated 0 times [  20] [ 0]  / answers: 1 / hits: 23031  / 1 Year ago, sun, january 22, 2023, 5:21:23

The best I could find via Google/man ls was:



ls -l | grep -v '^total'


Is there something I'm missing in the flags to ls?



Also, why is the total size in kb, regardless of the -h flag? scratch that, seems like it does, not sure what I was seeing then.


More From » ls

 Answers
6

Looking in the source code of coreutils, I found out that total will always be displayed when using the -l option on directories.



Using the -d option to list entries instead of directory contents hides total. But if you run that without arguments (or on a directory), it'll just show the directory and not its contents. Therefore, you need wildcards. * matches all files and .* matches hidden files as well (which corresponds with the -a option):



ls -ld * .*


As for the -h option, it works for me. 1118360 bytes show up as 1.1M. Files smaller than 1024 show up in bytes.


[#43519] Tuesday, January 24, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
donurp

Total Points: 328
Total Questions: 128
Total Answers: 123

Location: Faroe Islands
Member since Thu, Apr 8, 2021
3 Years ago
;