2

I would like for all my ls commands that display a date, such as ls -l, to print the date column in a format of my choosing. Currently, I manually set this every time with --time-style. Is there any way of permanently setting this to, say, long-iso (as opposed to issuing ls -l --time-style="long-iso" on every invocation)?

Thanks

4

If you define an alias such as

alias ls='ls --time-style=long-iso'

then ls invocations which end up displaying dates will use that.

  • I added this line to my .bashrc file, however, my colors have now disappeared! I'm guessing that this command is overwriting previous color options set to ls. Is there a way of telling the shell to simply append the --time-style option to the ls command? – aryzing Apr 12 '16 at 16:42
  • Check out unix.stackexchange.com/questions/124505 for various ways of stacking alias definitions; one of those should allow you to add --time-style=long-iso to your existing ls alias. – Stephen Kitt Apr 12 '16 at 17:07
0

This question is similar to the one asked on AskUbuntu, so I'll repeat the answer I put there:

export TIME_STYLE=<desired time style>

So, if you want all invocation of ls to produce output with --time-style=long-iso, you do:

export TIME_STYLE=long-iso

This method works on Ubuntu and Cygwin, and will likely work with all ls that comes from gnu coreutils (Mac OS X will need to install gnu coreutils using brew)

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.