LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   TIP - happy with the 'ls' command output? (https://www.linuxquestions.org/questions/linux-newbie-8/tip-happy-with-the-ls-command-output-662981/)

bashyow 08-15-2008 08:32 AM

TIP - happy with the 'ls' command output?
 
Ive always had a problem with the output of the 'ls' command when wanting to quickly view the sizes of files and sub-folders in a top-level folder, it never seemed quite right.

it seems to be better (for me at least) to use the 'du' (disk usage) command like this

'du --human-readable --all --max-depth=1'

you also get a nice total at the bottom.

ive got this aliased to 'duh' ;)

john test 08-15-2008 09:13 AM

Thanks for the tip. It does format nicely.:-)

MonctonJohn 08-15-2008 10:35 AM

I'll have to add that one to my alias list. I also have ll='ls -l' and la='ls -a'

john test 08-15-2008 01:28 PM

I didn't alias it to duh, I ppicked lu so from above I have la, ll, la and lu in my alias list
Thanks to both of you. :-)

DOSJockey382 08-15-2008 05:52 PM

ls -l covers pretty much 90% of my directory listing needs when I am not using display criteria and wild cards, like listing hidden files and directories (ls -l .*). I find this will give you the contents of hidden directories too. ls -dl will give you the just contents of the top directory listing of your criteria with no immediate subdirectory content listing.

John_J_Herda 08-16-2008 05:22 PM

Thanks and raise you one
 
Thanks for the tip. I took your duh and also made a duhs =
'du --human-readable --all --max-depth=1 | sort -k 2,2 '
Now the output is in order by filename (ascii or alphabetically).
However, the total is first instead of last.

bashyow 08-16-2008 07:04 PM

nice 1 john, good idea to pipe the output to sort :)

jpa42 08-18-2008 02:08 AM

nice and helpful. TKS. JP

rahmathullakm 08-19-2008 04:21 AM

i guess, the best one for the sorted human readable out of a directory contents in a clean way is

$ ls -rShl (its more simple, right? try this)

then if you want to go for a total size, then do $ du -sh

again for the users who want to stick with du (who dont like ls), let me make the first commands little more simple;

$ du -h --max-depth=1

thats all..

von Stalhein 08-19-2008 05:04 AM

Quote:

Originally Posted by rahmathullakm (Post 3252384)
i guess, the best one for the sorted human readable out of a directory contents in a clean way is

$ ls -rShl (its more simple, right? try this)

then if you want to go for a total size, then do $ du -sh

again for the users who want to stick with du (who dont like ls), let me make the first commands little more simple;

$ du -h --max-depth=1

thats all..

Thanks for that - it's very useful, I'd been wondering how to do something like that from a cli :-)

apeekaboo 08-19-2008 03:48 PM

Quote:

Originally Posted by rahmathullakm (Post 3252384)
i guess, the best one for the sorted human readable out of a directory contents in a clean way is

$ ls -rShl (its more simple, right? try this)

Nice, I liked this.

Added to my list of ls aliases:
Code:

alias ls='ls -F --color=auto'    # color the output, classify files
alias ll='ls -lh'                # ls with long listing, human readable format
alias lsr='ll -rt'                # ls with long listing, recently changed last
alias ls1='ls -1'                # ls with each entry on its own line
alias lss='ll -rS'                # ls with long listing, biggest files last

Oh, by the way.
If you'd like to use a regular ls, without using any of the aliases, just use:
Code:

\ls
The backslash makes the shell interpret your command literally.


All times are GMT -5. The time now is 02:03 PM.