Search / Find files modified in the last x days with Bash in Terminal

March 13th, 2020 admin Location: Raleigh, NC, Topic: Web Design | Digital Media

So, if you are like me, sometimes for any number of reasons, you have to find all the files of a certain type that have been modified lately. For example, if a client had a security problem with their website and you would like to check what files where modified since the last backup. Or let’s say that you don’t remember what files you modified the last time that you made some changes to a directory, etc.

Here it is:

find directory_name/ -mtime -days_number -ls | grep "php"

Find is the command name that we are going to use.

directory_name is the name of the directory that you want to search. For example, you would search in www/ or in public_html/

-mtime is the flag that states modified time.

-days_number is a number, either positive or negative , for the files in days. So for example: -10 (means modified in the last 10 days).

-ls means list them.

| the pipe symbol passes the output of the first declaration to the input of the second declaration.

grep is used to match. In this case, in the results, find the files that have a “php” or a “jpg” or anything that you want.

And that is it! You don’t need anything else. Hope that helps –


About the Author

Alex Centeno MBA., is an international creative director and digital media strategist. Currently residing minutes away from the Research Triangle Park (RTP) - North Carolina, and with over 10 years of interactive marketing training and experience, Alex leads Merkados' international clients to maximizing their online business strategies. One of Alex's biggest strengths is his world-class capacity to effectively combine interactive marketing, digital media design and web development.

You may find further information about Alex Centeno MBA. at: and Twitter.

Sobre el Autor

Alex Centeno MBA., Es un director creativo y estratega de medios digitales reconocido internacionalmente. En la actualidad reside a tan solo minutos del Research Triangle Park (RTP) - Carolina del Norte, y con más de 10 años de entrenamiento y experiencia en marketing interactivo, Alex lidera a los clientes internacionales de Merkados™ para maximizar sus estrategias de negocios en línea. Una de las mayores fortalezas de Alex es su capacidad global de combinar de manera efectiva, mercadeo interactivo, diseño de medios digitales y desarrollo web.

Para más información sobre Alex Centeno MBA. puede visitar: y Twitter.