2 thoughts on “ls — sort by size

  1. This sorts alphabetically by size, which is not very useful as it will put 941 after 9361, for example. You have to add -n to the sort command, like this:

    ls -s | sort -n
    ls -al | sort -n +4

    Like

  2. @angelabrett, in my experience, straight sort without -n was practical and useful even if sometimes imperfect. If I need a robust solution i'd write a perl one-liner.

    Thanks for the correction anyway.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s