28

Is there any command to display the recently modified/created files?

Which one...?

3 Answers 3

29

Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

find ${1} -type f | xargs stat --format '%Y :%y %n' 2>/dev/null | sort -nr | cut -d: -f2-

See Find command

Source:Linux

6
  • The command is correct. Have you tried it?
    – Mitch
    Jan 27, 2014 at 11:51
  • Yeah,it's correct,it just takes some time.I thought -f2- would be incorrect because commands don't generally end with an - Jan 27, 2014 at 11:56
  • Nice one! What about ignoring hidden files? Jan 27, 2014 at 11:57
  • You can use -iname. For example, find *.txt file but ignore hidden .txt file such as .vimrc you would -type f \( -iname "*.txt" ! -iname ".*" \).
    – Mitch
    Jan 27, 2014 at 12:04
  • @Mitch how to specify to find files in last 2 days?
    – user13107
    May 8, 2014 at 2:36
14

Check stat command:

Usage:

stat [options] filename ... ...

e.g.

stat /home/user/Docs/filename.txt

To search for files, use find commands:

e.g.

find /to/target/directory* -mtime -1

(the switch -mtime n show file's with data last modified n*24 hours ago, for -mtime -1 the files 1 day old will be shown)

find /to/target/directory* -mmin 30

will show files modified in last 30 minutes.

Check for more options under TESTS in the manual pages (use man find in terminal). You can use other switches like -amin n (last accessed n minutes ago), -cmin (file's status was last changed n minutes ago), and others.

7
  • Maybe you could consider either removing the stat part from your answer or giving a specific command. Jan 27, 2014 at 11:48
  • stat filename where filename could be your target's absolute or relative path. This will show access, modification, change times among other outputs..
    – rusty
    Jan 27, 2014 at 11:54
  • stat will also give you the file's birth time if the filesystem supports that..
    – rusty
    Jan 27, 2014 at 11:55
  • 1
    The asker wants to see a list of recently changed files.stat gives out properties of a specific file or directory(like when it was modified last time). Therefore this command is not appropriate for this question. Jan 27, 2014 at 12:02
  • ..it's related, isn't it? It shows you the time stamps.. and what OP want's is a practical implementation of the same..
    – rusty
    Jan 27, 2014 at 12:12
5
ls -t

This will sort the list of files by modification time

You must log in to answer this question.

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