ls or sort on size ??
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > ls or sort on size ??




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    ls or sort on size ??  
Nithya Venkatachalam


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-24-04 07:50 AM

Hi,
Is there anyway to list a set of files in a directory whose size is
greater than some value?
Or to display in sorted order by size? Any UNIX command?
Nithya






[ Post a follow-up to this message ]



    Re: ls or sort on size ??  
Pascal Bourguignon


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-24-04 07:50 AM

"Nithya  Venkatachalam" <vnithya@gmail.com> writes:

> Hi,
> Is there anyway to list a set of files in a directory whose size is
> greater than some value?

man find

> Or to display in sorted order by size? Any UNIX command?

man sort


--
__Pascal Bourguignon__                     http://www.informatimago.com/

Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we.





[ Post a follow-up to this message ]



    Re: ls or sort on size ??  
Stephane CHAZELAS


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-24-04 07:50 AM

2004-09-23, 22:12(-07), Nithya  Venkatachalam:
> Is there anyway to list a set of files in a directory whose size is
> greater than some value?

Use the zsh shell:

print -rl -- *(L+100)

lists the files larger than 100 bytes.

> Or to display in sorted order by size? Any UNIX command?
> Nithya

print -rl -- *(oL)

lists the files sorted by size.

--
Stephane





[ Post a follow-up to this message ]



    Re: ls or sort on size ??  
Nithya Venkatachalam


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-24-04 12:49 PM

Thanks.
And ls -l | sort -n -k 5,5

served my purpose of listing sorted by size.
5 is the column number in which size is displayed in ls -l.






[ Post a follow-up to this message ]



    Re: ls or sort on size ??  
Nithya Venkatachalam


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-24-04 12:49 PM

Thanks.
And ls -l | sort -n -k 5,5

served my purpose of listing sorted by size.
5 is the column number in which size is displayed in ls -l.






[ Post a follow-up to this message ]



    Re: ls or sort on size ??  
Måns Rullgård


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-24-04 12:49 PM

"Nithya  Venkatachalam" <vnithya@gmail.com> writes:

> Thanks.
> And ls -l | sort -n -k 5,5
>
> served my purpose of listing sorted by size.

ls -lS does the same thing.

--
Måns Rullgård
mru@mru.ath.cx





[ Post a follow-up to this message ]



    Re: ls or sort on size ??  
Måns Rullgård


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-24-04 12:49 PM

Måns Rullgård <mru@mru.ath.cx> writes:

> "Nithya  Venkatachalam" <vnithya@gmail.com> writes:
> 
>
> ls -lS does the same thing.

Sorry, that sorts in descending order.  To sort ascending, use ls -lSr.

--
Måns Rullgård
mru@mru.ath.cx





[ Post a follow-up to this message ]



    Re: ls or sort on size ??  
Stephane CHAZELAS


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-24-04 12:49 PM

2004-09-24, 12:26(+02), Måns Rullgård:
> Måns Rullgård <mru@mru.ath.cx> writes:
> 
>
> Sorry, that sorts in descending order.  To sort ascending, use ls -lSr.

-S is a GNU specific option.

--
Stephane





[ Post a follow-up to this message ]



    Re: ls or sort on size ??  
Juergen Pfann


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-25-04 07:50 AM

Nithya Venkatachalam wrote:
> Hi,
> Is there anyway to list a set of files in a directory whose size is
> greater than some value?
> Or to display in sorted order by size? Any UNIX command?
> Nithya
>

Don't forget, 'ls' means 'list sorted' anyway ;-)).
Hence, it should not be too complex to take the files'
sizes, rather than their names, as the sorting criterium...

For ex., on the Linux system I'm typing this, ls is

$ LC_MESSAGES=C ls --version
ls (fileutils) 4.1
Written by Richard Stallman and David MacKenzie.
(...)

i.e. the GNU implementation.

The resp. manpage reveals

-S     sort by file size

ad libitum to be combined with

-r, --reverse
reverse order while sorting

Voilà, as for the 2nd question.

For the 1st one: In one of my scripts, I use the line

find /var/spool/news -type f -size +10k -not -name '.overview' -ls | \
sort -k 7,8 -n | uniq -c -w 67 >~/Log.size.news

Again, the '-ls' option to 'find' is a GNU speciality AFAIK.
[But you weren't specific about the particular Unix / Unixoid system
you asked for. And IMHO, this question would have been more suitable
to c.u.questions or c.u.shell.]

Juergen






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:58 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register