Does the ls command have any functionality to show the column headers for decoding what the columns are? I'm aware of the portion of support text that describes the columns in
info ls
I've a function as below in my ~/.profile
, for the same reasons,
k(){
{ echo PERMS LINKS OWNER GROUP SIZE modMONTH modDATE modTIME NAME
ls -l; } |
column -t |
grep -v "total"
}
Similar to the @Niranjan answer, taken from the man of column
command:
EXAMPLES
(printf "PERM LINKS OWNER GROUP SIZE MONTH DAY " ; \
printf "HH:MM/YEAR NAME\n" ; \
ls -l | sed 1d) | column -t
This question was also asked on SO – sharing my answer here as well:
exa is a replacement/enhancement for ls
. If you pass on the arguments -lh
with exa, it will include a header row printing the column names like so:
exa -lh
Example output:
Permissions Size User Date Modified Name
.rwx------ 19 username 29 Sep 11:25 dont_cra.sh
drw-r----- - username 29 Sep 11:26 f1
.rw-r--r--@ 811k username 29 Sep 11:25 row_count.dat
.rw-r--r-- 54 username 29 Sep 11:25 some_text.txt
You can set up an alias in .bashrc that replaces ls with exa.
No.
The ls
command does not have any support for printing column headers. Any solution will require external processing of the results of the ls
command.