How to set ls -lh with time and long date format in descending order in .bashrc

datelssort

I tried setting the following alias in .bashrc –

$ alias ll
alias ll='ls --color=auto --time-style=long-iso'

But the above doesn't work. I want to have the long-iso as well as descending order (date or/and time-wise) whenever I ask it to list files in CLI. Is there anyway to do that ?

The above command does give me color output but not long-iso part. Am I doing something wrong ?

I did see Set ls -l time format but doesn't help in my case 🙁

Best Answer

You are missing a -l to turn on the long listing format and -t to sort by modification time.

Do:

alias ll='ls -lt --color=auto --time-style=long-iso'

To include hidden files too:

alias ll='ls -alt --color=auto --time-style=long-iso'

To reverse the order of sorting, oldest first, add -r:

alias ll='ls -ltr --color=auto --time-style=long-iso'
alias ll='ls -altr --color=auto --time-style=long-iso'