Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6815841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:51:18+00:00 2026-05-26T20:51:18+00:00

I wanted to do some changes to the ls -l command. First, I wanted

  • 0

I wanted to do some changes to the ls -l command.

First, I wanted to remove the first “total X” line as I don’t use it.

Then, I wanted to show directories topmost. (Or, more precisely, sort according to type.)

Third, I wanted to sort according to name in cases of identical type.

This would be almost trivial to write in a script or functional language, or even in C, but I got inspired by something I read that you should not write new stuff for everything, but rather combine the tools you have. Some hours (!!) later, I came up with this:

ls -l | tac | head -n -1 | sort -k 1.1,1.2 -k 9

Feeling a bit silly, it seems to work. But:

Slower:

real 0m0.009s
user 0m0.008s
sys 0m0.008s

instead of ls -l:

real 0m0.003s
user 0m0.004s
sys 0m0.000s

No colors! (With ls -l, dictionaries are blue, etc.)

So, if you know of a better way, shoot 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:51:19+00:00Added an answer on May 26, 2026 at 8:51 pm

    man ls, I mean really, try it.

    For 2nd, 3rd and no colors

    $> ls -l --group-directories-first --sort=extension --color=never
    

    If you need colors you should use --color=auto or --color=always.

    For the 1st question there is a duplicate, for example.

    Actually, you can remove first line with awk:

    awk '{ if ( NR > 1 ) print }'
    

    So resultant command looks like

    $> ls -l --group-directories-first --sort=extension --color=always | awk '{ if ( NR > 1 ) print }'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started a feature branch B from branch A. Then I made some changes
Just wanted some quick help I'm 90% sure i need to use the (this)
I wanted some of those spiffy rounded corners for a web project that I'm
I just wanted some opinions from people that have run Selenium ( http://selenium.openqa.org )
I would like to learn ASP.NET and just wanted some input as to which
I'm about to port a smallish library from Java to Python and wanted some
I know the topic I started is too subjective. But I just wanted some
Wanted to get some consensus around a UI feature I'm working on right now.
I wanted to set some handler for all the unexpected exceptions that I might
I wanted to make some simple file recovery software, where I want to try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.