3

How can I use ls while using -l (long listing) without showing the file permissions?

This is what I want displayed when executing <code>ls</code>

Right now I have the following alias for ls:

alias ls='ls -lhaG --color=auto'

I have found a solution close to what I'm looking for, but it doesn't maintain the syntax colouring or spacing.

2

ls -lhaG --color=always | sed -re 's/^[^ ]* //'

--color=always makes ls always output colour ESC codes, even when piping to another program.

The sed script removes the first field (the permissions).

NOTE that if you have $LS_OPTIONS='--color=auto' in the environment, then that will override the --color=always option on the command line. In that case, run it like this:

LS_OPTIONS= ls -lhaG --color=always | sed -re 's/^[^ ]* //'

NOTE ALSO that you will probably regret making ls an alias for this as it will make it a PITA to redirect directory listings to a file or to pipe them into another program without getting the ESC colour codes in the output. To see just how ugly this is, try ls -lhaG --color=always | sed -re 's/^[^ ]* //' | cat -A

  • Thank you for that last note, I'll have to make a separate alias for this output. – spenser_l Oct 24 '15 at 3:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.