All help topics · Link to this topic
Showing help on 'file_grep()'
Function: LIST file_grep(FHANDLE fh, STR search [,?match_all = 0])Search for a string in a file.
Assume we have a file `test.txt` with the contents:
asdf asdf 11
11
112
And we have an open file handle from running:
;file_open("test.txt", "r-tn")
If we were to execute a file grep:
;file_grep(1, "11")
We would get the first result:
{{"asdf asdf 11", 1}}
The resulting LIST is of the form {{STR match, INT line-number}}
If you pass in the optional third argument
;file_grep(1, "11", 1)
we will receive all the matching results:
{{"asdf asdf 11", 1}, {"11", 2}, {"112", 3}}