MATLAB: How to make ‘Find Files’ return file names only once in MATLAB 7.9 (R2009b)

MATLAB

When I look for files containing some text, 'Find File' returns every occurrence of the text. This leads to the same file being reported multiple times. I want to be able to see each file being reported only once.

Best Answer

By default, the Find Files feature performs a simple LS command on the underlying directory structure.
To return file names that contain the text only once, you can call command-line shell tools like GREP on Unix-based operating systems. Then, you can use the UNIQUE function in MATLAB, with the 'first' parameter argument, on the string array returned by GREP to satisfy this requirement.
For more information, please take a look at the system documentation for GREP on Unix machines, or consider using a third-party tool like Windows Grep (see below) on Windows machines:
<http://www.wingrep.com/>