JANOS Help System: [Commands] [Topics] [Tech Support] [Printable Manual] [Search]
EGREP/GREP/FIND User Commands NAME find - File Search Utility ALIASES FIND, GREP, EGREP SYNOPSIS find [OPTIONS] SEARCH FILE egrep [OPTIONS] REGEX FILE DESCRIPTION This command searches a text FILE for matches to a specified SEARCH string. Each line containing a match is displayed. FIND and GREP search for an exact match to the string. Case-dependent and case-independent searches are possible. Regular Expressions (REGEX) are used with EGREP or when optionally selected. -E Use Regular Expressions (REGEX) for searches. This is the default with the command alias EGREP. -C Counts the number of lines with matches. Only the resulting count is reported. -N Displays the line number in the FILE for each matching line. -H Displays the FILE specification and line number for each matching line. -I Performs a case-independent search. -M This displays each matching line and subsequently underlines the matched text with a series of dashes '---'. When this option is used with REGEX the captured Groups as may be specified in the Regular Expression using parentheses ( ) are displayed. -F FORMAT Output formatting using REGEX results. The FORMAT specifies an output string that is generated for each match. The group specifiers $1, $2, $3, etc. are replaced by the first, second, third, and so on group matches. NOTES The output formatting option -F can be used to format a readable string or even a command that might be subsequently executed. For example the following extracts NTP server IP addresses from the syslog and generates PING commands to test NTP server validity (and response time). egrep sync.+(\d+\.\d+\.\d+\.\d+) jniorsys.log -f "@ping -qc 1 $1" | exec This results in PING command responses like these: Reply from 129.146.193.200 (66ms) Reply from 45.79.111.167 (69ms) Reply from 162.159.200.123 (21ms) Reply from 208.76.2.12 (79ms) No reply from 65.100.46.164 Reply from 45.33.65.68 (28ms) The REGEX group matches an IP Address from the jniorsys.log file which is included in a series of formatted PING commands. The result is piped to an EXEC command that runs the piped list as if it were a batch file. Note that beginning with JANOS v2.4 both the Stratum and RTT (response time) are included in the system log when NTP time synchronization occurs. SEE ALSO HELP Topics: BATCH, PING, REGEX [/flash/manpages/manpages.hlp:2486]