Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

Search for files modified the last ... days

Searches for files modified up to 4 days ago. Change the 4 to whatever you desire.

find ./ -type f -mtime -4 -exec ls -al {} \;

Find files with a certain extension, where the files contain a certain search term

Searches the current directory and deeper for files ending with the 'php' extension, where the file itself contains 'search_term'. Useful if you're searching a large website with lots of images and you only want to find a certain function or variable.

find ./ -type f -name \*.php -exec grep -il "search_term" {} \;

Find files with certain extensions

Searches the current directory and deeper for several extensions. In this example both files mathing 'php', 'html' and 'tpl' match the search.

find ./ -regex ".*\(php\|html\|tpl\)$"


As an alternative you could also use:

find ./ -iname "*.php" -or -iname "*.tpl" -or -iname "*.html"

Find files with a certain extension

Searches the current directory and deeper for all files having an extension 'php'. Change this to the extension you're looking for.

find ./ -type f -name \*.php
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS