SEARCHFILE - Search a text file for matching records and extract them into an array |
Top Previous Next |
This script command is used to search a file for matches to search string. This command can serve one of 2 purposes. When used without /regex it can tell you how many times a string occurs in a file which will be stored as a number in varname. When used with the /regex option it becomes much more powerful and can be used to extract all matching records from a file into an array. In this case varname takes the following form.
Suppose you wanted to get all the error messages out of a Robo-FTP script log file...
[2015-12-23 12:37:02.274000|info]Robo-FTP v3.10.0.43 SN: 021141000309 [2015-12-23 12:37:02.278000|info]Copyright © 2015 Serengeti Systems Incorporated. [2015-12-23 12:37:02.280000|info]ALL RIGHTS RESERVED. [2015-12-23 12:37:04.729000|info]CMD: display mine [2015-12-23 12:37:04.730000|error]*Variable(s) not assigned or not present. [1009] [2015-12-23 12:37:06.390000|info]CMD: exit [2015-12-23 12:37:06.391000|info]*Exit Robo-FTP.
You could use SEARCHFILE "Robo-FTP_Script.log" "^.*\|error](.*)$" errors /regex
After which
Related command(s): READFILE See also: Regular Expressions |