1

I want to produce a list of files in a directory and feed it into a script to generate database entries including their creation dates. The database is Solr, so I need to be able to translate ISO 8601 yyyy-mm-ddThh:mm:ssZ format (although I don't really care if the timezone is off, it's a bit quick and dirty).

ls appears to be the obvious choice, but doesn't print the year in the creation date. And the format is weird. And it doesn't seem that I can just choose the columns I want, which is annoying.

What other tool might be more friendly to simple text processing a la Awk?

1 Answer 1

1

The stat command will output the modification time like this:

$ stat -c %y somefile
2012-02-21 23:06:11.893609899 -0800

The man page describes other available output formats.

1
  • 1
    Thanks! All I needed was stat -f '%c %N' *. May 11, 2012 at 4:17

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.