Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

up vote 4 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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.