Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux: search for files of type *.php recently modified

Tags:

linux

find

How do I adapt this to return recursively files of only extension *.php? thx!

find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort
like image 264
Stoob Avatar asked Dec 15 '11 00:12

Stoob


People also ask

How do I find recently modified files in Linux?

Method 1: Using stat command. Stat command can be used to display timestamps of a file. Example 2: Using the ls command. By using this command you can list only today's files in your home folder.

How do you check if a file has been modified in Linux?

-mtime n is an expression that finds the files and directories that have been modified exactly n days ago. In addition, the expression can be used in two other ways: -mtime +n = finds the files and directories modified more than n days ago. -mtime -n = finds the files and directories modified less than n days ago.

How do I find the last modified directory in Linux?

You can use the ls command to list files including their modification date by adding the -lt flag as shown in the example below. The flag -l is used to format the output as a log. The flag -t is used to list last modified files, newer first.

How can you find all log files that have been modified more than 30 days ago?

find is the Unix command line tool for finding files (and more) /directory/path/ is the directory path where to look for files that have been modified. Replace it with the path of the directory where you want to look for files that have been modified in the last N days.


1 Answers

Add -name '*.php':

find . -type f  -name '*.php' -printf '%TY-%Tm-%Td %TT %p\n' | sort

Note that since the expression is evaluated by find from left to right you must specify the -name test before the -printf action.

See this manpage for details about tests, actions and how find evaluates your expression.

like image 115
Adam Zalcman Avatar answered Oct 07 '22 20:10

Adam Zalcman