-1

Does anyone know a way to re-arrange the ls -al returned list in a way that:

a) Directories first, files after;

and

b) Date first, name second and permissions at the end

and

c) Without losing color. (CLICOLOR=1 do exist)

and

d) All this on a ls -al alias ?

MEM
  • 1,387

1 Answers1

2

How about

ls -la --color=yes --group-directories-first | awk '{print $6 "\t" $8 "\t\t" $1}'

About the alias, aliases cannot contain variables, but a solution would be functions. They are stored in .profile/.bashrc and work just like aliases.

EDIT: Function is below - just add it to your .profile, open a new shell and type myls. Works like a charm :)

myls () { ls -la --color=yes --group-directories-first | awk '{print $6 "\t" $8 "\t\t" $1}'; }
Silviu
  • 684
  • 6
  • 16