26

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?

34

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.

  • -printf does not work in OS-X. Is there an equivalent to this command that will work for OS-X? – WanderingMind Jun 5 '17 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 Jun 6 '17 at 19:05
22

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.

  • I gave an upvote, but this does not show the date properly, so it is difficult to find the "newest" for instance. – lpapp Mar 3 '15 at 9:31
  • This is the only place where I came to know about -ls option which I was needing badly – Atul Nov 29 at 5:08
-1

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

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

This works for me:

$ find ./ -name "*.sqlite" -ls
  • 4
    This appears to be a complete duplicate of @Caleb's answer. – Chris Down Feb 21 '14 at 1:33

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.