Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I get both ctime and atime in ls output? Seems I can only pass one --time=ctime or --time=atime argument (the second is ignored). Is there any other way?

share|improve this question
up vote 6 down vote accepted

You could run stat -c '%x %z' filename.txt

share|improve this answer

If you are only parsing values out of ls, you can use stat instead:

# stat -c %x,%z,%n *
2011-01-11 06:09:04.000000000 -0500,2011-01-11 02:43:52.000000000 -0500,sqlupdate.sh
2011-01-11 06:09:04.000000000 -0500,2011-01-12 02:43:55.000000000 -0500,file.tar.gz
2011-01-11 06:09:04.000000000 -0500,2011-01-11 02:43:52.000000000 -0500,mysql_password.txt
2011-01-17 02:43:49.000000000 -0500,2011-01-12 13:40:48.000000000 -0500,public_html

Where:

 %x     Time of last access
 %z     Time of last change
 %n     Name of file
share|improve this answer
    
Just to be sure I understand the answers here. It is possible with ls to display any of access, modified and change time, but not more than one at a time. Because that is both really surprising, and very annoying. – Mads Skjern Jul 28 '15 at 12:49

with findyou get very close to what ls -lprovides:

# find . -maxdepth 1 \
     -printf "%M %u %g %s\t%Ab %Ad %AH:%AM\t%Cb %Cd %CH:%CM\t%P\n"

you have access to ctime (%C), atime(%A) and modification time (%T). read man find to find more info.

share|improve this answer

You must log in to answer this question.

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