LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 08-15-2008, 08:32 AM   #1
bashyow
Member
 
Registered: Jun 2008
Location: uk
Distribution: Slackware 12.1, AND IM LOVIN EVERY MINUTE OF IT, JERRY! :D
Posts: 122

Rep: Reputation: 15
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'
 
Old 08-15-2008, 09:13 AM   #2
john test
Member
 
Registered: Jul 2008
Distribution: ubuntu 9.10
Posts: 527
Blog Entries: 1

Rep: Reputation: 35
Thanks for the tip. It does format nicely.:-)
 
Old 08-15-2008, 10:35 AM   #3
MonctonJohn
Member
 
Registered: Aug 2007
Location: Canada
Distribution: Mint
Posts: 112

Rep: Reputation: 15
I'll have to add that one to my alias list. I also have ll='ls -l' and la='ls -a'
 
Old 08-15-2008, 01:28 PM   #4
john test
Member
 
Registered: Jul 2008
Distribution: ubuntu 9.10
Posts: 527
Blog Entries: 1

Rep: Reputation: 35
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. :-)
 
Old 08-15-2008, 05:52 PM   #5
DOSJockey382
LQ Newbie
 
Registered: Aug 2005
Location: California
Distribution: Debian, Ubuntu, NetBSD, OS X
Posts: 25

Rep: Reputation: 15
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.
 
Old 08-16-2008, 05:22 PM   #6
John_J_Herda
LQ Newbie
 
Registered: Feb 2006
Posts: 1

Rep: Reputation: 0
Thumbs up 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.
 
Old 08-16-2008, 07:04 PM   #7
bashyow
Member
 
Registered: Jun 2008
Location: uk
Distribution: Slackware 12.1, AND IM LOVIN EVERY MINUTE OF IT, JERRY! :D
Posts: 122

Original Poster
Rep: Reputation: 15
nice 1 john, good idea to pipe the output to sort
 
Old 08-18-2008, 02:08 AM   #8
jpa42
LQ Newbie
 
Registered: Jul 2006
Posts: 5

Rep: Reputation: 0
nice and helpful. TKS. JP
 
Old 08-19-2008, 04:21 AM   #9
rahmathullakm
LQ Newbie
 
Registered: Jul 2008
Posts: 15

Rep: Reputation: 0
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..
 
Old 08-19-2008, 05:04 AM   #10
von Stalhein
LQ Newbie
 
Registered: Jul 2008
Location: Thurgoona, Australia
Distribution: Ubuntu 11.10
Posts: 25

Rep: Reputation: 0
Quote:
Originally Posted by rahmathullakm View Post
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 :-)
 
Old 08-19-2008, 03:48 PM   #11
apeekaboo
Member
 
Registered: Apr 2003
Location: Stockholm/Sweden
Distribution: Kubuntu, Debian, Slax
Posts: 91

Rep: Reputation: 16
Quote:
Originally Posted by rahmathullakm View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to paginate in the 'LS' command? jhecht Linux - Software 10 04-13-2010 06:15 AM
Listing directories first with 'ls' command Lufbery Linux - Newbie 6 01-16-2007 08:22 AM
can 'ls' command be recursive? Hailey's_Comet Linux - Newbie 3 10-01-2006 12:29 AM
Unexpected output from 'ls' when using glob expressions psiakr3w Linux - General 7 07-22-2004 03:21 AM
'ls' command... sramelyk Slackware 7 10-01-2003 12:45 PM


All times are GMT -5. The time now is 03:54 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration