File Exchange

image thumbnail

Grep Values from a file.

version (9.19 KB) by Anver Hisham
Function to grep values of a parameter from an input file to matrix. Supports multiline grepping.


Updated 23 Dec 2013

View License

1. To grep parameter 'a' from file 'file1.txt' which contains numbers as "a=[1 2 3]",
a = grepValues('file1.txt','a');
2. To grep parameter 'a' from file 'file1.txt' which contains string as "a= citizen kane",
clear options;
a = grepValues('file1.txt','a',options);
3. To grep all parameters ending on 'a', input a PERL-REGEX pattern as parameter name,
clear options;
a = grepValues('file1.txt','\w*a',options);
4. To count the occurances of all parameters ending on 'a', make searchMode as 'countOnly'
clear options;
a = grepValues('file1.txt','\w*a',options);

For more info, see the comments on top of file.

MATLAB release: MATLAB 6.5 (R13)
Other requirements: Thoroughly tested in the Linux environment, in R12 and R13. For other platforms, Perl 5 is required.

Cite As

Anver Hisham (2020). Grep Values from a file. (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)


Minor Bug fixed, which prevented grepping of double quoted matrices.

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux