48

In bash, if I use $ find ./ -name "*.sqlite" , it will list all the sqlite files in current directory. I also want to see the modified time of the files, can anybody give me some help?

3 Answers 3

58

You can add to find the following expression:

-printf '%Tc %p\n'

to see something like

Sun Aug 14 06:29:38 2011 ./.nx/config/host.nxs

or -printf '%TD %TT %p\n' for

08/14/11 06:29:38.2184481010 ./.nx/config/host.nxs

or -printf '%T+ %p\n' if you have GNU find, to see

2011-08-14+06:29:38.2184481010 ./.nx/config/host.nxs

This last one, if available, is also useful for time sorting purposes.

See manual page of find, where it talks about printf.

2
  • 2
    -printf does not work in OS-X. Is there an equivalent to this command that will work for OS-X? Commented Jun 5, 2017 at 15:53
  • @WanderingMind: in OS-X I suggest to install MacPorts that provides many UNIX applications, in particular GNU tools, like GNU find.
    – enzotib
    Commented Jun 6, 2017 at 19:05
36

A quick hack to get more details about the files found by find is to use the -ls output option.

find ./ -name "*.sqlite" -ls

For more precise results enzotib's answer is spot on.

3
  • I gave an upvote, but this does not show the date properly, so it is difficult to find the "newest" for instance. Commented Mar 3, 2015 at 9:31
  • This is the only place where I came to know about -ls option which I was needing badly
    – Atul
    Commented Nov 29, 2019 at 5:08
  • Example output screenshot at cyberciti.biz/faq/…
    – mwfearnley
    Commented Apr 14, 2020 at 15:50
2

Use below command to get list of files with time stamp.

$ find . -type f | xargs ls -l --time-style="+%d-%m-%Y" 

You must log in to answer this question.

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