View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

5.0 | 3 ratings Rate this file 5 Downloads (last 30 days) File Size: 3.76 KB File ID: #813 Version: 1.0
image thumbnail



Brett Shoelson (view profile)


30 Sep 2001 (Updated )

Returns the names of all m-files within the specified path containing a specified search string.

| Watch this File

File Information

Like the "grep" functionality in the GNU Project, this program searches files for the presence of a search string. However, mfilegrep searches only mfiles. Searches can be recursive or non-recursive, and case-sensitive or non-case-sensitive, and can search for whole words or partial words. The result is returned in a cell array that contains the names of all mfiles on the specified path that contain the search string. Additionally, the user has the option of listing the text of all lines in the mfiles containing the search string.


This file inspired Mgrep.

MATLAB release MATLAB 6.1 (R12.1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
13 Jan 2006 John D'Errico

Careful application of profile to mfilegrep found a spare call to intersect. Long searches spent 90% of their time in that one line. I've fixed that, and several other (minor) bugs in mgrep.

Comment only
14 Oct 2005 Karl-Heinz Rigerl

Great for cleaning up bigger applications, same name for same variables in all m-files.

17 Mar 2004 Bill Driscoll

Thank you, Brett, for this great routine. I find mfilegrep more convenient than dos('grep etc etc').

17 Nov 2003 Harvey Greenberg

Very useful!

04 Oct 2001

I omitted one of the possible input arguments in my descriptive comments.

Contact us