8

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 :(

2 Answers 2

13

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'
8
  • That works but doesn't have any descending order in listing of files wth respect to the date and time. Is there a way to do that as well ?
    – shirish
    Oct 8, 2016 at 21:56
  • @shirish Check my edits
    – heemayl
    Oct 8, 2016 at 22:00
  • 2
    You also need -t to order by last modification time. Oct 8, 2016 at 22:02
  • @StéphaneChazelas Was into that, but Gilles incorporated that already.
    – heemayl
    Oct 8, 2016 at 22:10
  • @Giles and @heemayi - a mistake, both seem to have -r , the first one one should not have 'r' in the flag ` -lt`
    – shirish
    Oct 9, 2016 at 7:42
2

An alternative to passing --time-style to ls is to set the TIME_STYLE environment variable.

e.g. in .bashrc

export TIME_STYLE=long-iso

Documented in coreutils.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .