Here are a few alternatives; One is the use of shell expressions, the other is a relative of grep, agrep:
producing:
The agrep will be much faster for files of more than trivial size.
I want to search files (basically .cc files) in /xx folder and subfolders.
Those files (*.cc files) must contain #include "header.h" AND x() function.
I am writing it another way to make it clear,
I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
hey guys,
Hey all,
I'm doing a project currently and want to index words in a webpage.
So there would be a file with webpage content and a file with list of words, I want an output file with true and false that would show which word exists in the webpage.
example:
Webpage content... (2 Replies)
Hi to all
Sorry for the confusion because I did not explain the task clearly.
There are many .hhr files in a folder
There are so many lines in these .hhr files but I want only the following 2 lines to be transferred to the output file.
The keyword No 1 and all the words in the next line
They... (5 Replies)
Hi
I am trying to determine number of lines having a specific keyword.
So for that I am using below query:
grep -i 'keyword1' filename|wc -l
This give me number of lines. Perfect for me.
However now the requirement is
I have multiple keywords together... and I have to find number of... (3 Replies)
Hi,
I have a file containing list of strings like
i:
Pink
Yellow
Green
and I have file having list of file names in a directory
j :
a
b
c
d
Where j contains of a ,b,c,d are as follows
a:
Pink (3 Replies)
Hi,
I want to grep multiple patterns from multiple files and save to multiple outputs. As of now its outputting all to the same file when I use this command.
Input : 108 files to check for 390 patterns to check for. output I need to 108 files with the searched patterns.
Xargs -I {} grep... (3 Replies)
I have below text file only with one line:
vi test.txt
This is the first test from a1.loa1 a1v1, b2.lob2, "c3.loc3" c3b1, loc4 but not from mot3 and second test from a5.loa5
Below should be the output that i want:
a1.loa1
b2.lob2
c3.loc3
loc4
a5.loa5
alv1 and c3b1 should be... (3 Replies)
The Problem that I am having is when the code ran and populated the progflag.csv file, columns MEMSIZE, SECOND and SASEXE were blank. The next problems are the IF else statement isn't working and the email function isn't sending the progflag.csv attachment.
a. What I want the program to do is to... (2 Replies)
I have several problems with my program: I hope you can help me.
1) the If else statement isn't working . The IF Else syntax is:
If MEMSIZE OR sasfoundation (SASEXE) OR Real Time(second) >1.0 and Filename, output column name and value to csv or else nothing
Example progflag,cvs:... (13 Replies)
Discussion started by: dellanicholson
13 Replies
LEARN ABOUT SUNOS
egrep
egrep(1)egrep(1)NAME
egrep - search a file for a pattern using full regular expressions
SYNOPSIS
/usr/bin/egrep [-bchilnsv] [-e pattern_list] [-f file] [strings] [file...]
/usr/xpg4/bin/egrep [-bchilnsvx] [-e pattern_list] [-f file] [strings] [file...]
The egrep (expression grep) utility searches files for a pattern of characters and prints all lines that contain that pattern. egrep uses
full regular expressions (expressions that have string values that use the full set of alphanumeric and special characters) to match the
patterns. It uses a fast deterministic algorithm that sometimes needs exponential space.
If no files are specified, egrep assumes standard input. Normally, each line found is copied to the standard output. The file name is
printed before each line found if there is more than one input file.
/usr/bin/egrep
The /usr/bin/egrep utility accepts full regular expressions as described on the regexp(5) manual page, except for ( and ), ( and ), {
and }, < and >, and
, and with the addition of:
1. A full regular expression followed by + that matches one or more occurrences of the full regular expression.
2. A full regular expression followed by ? that matches 0 or 1 occurrences of the full regular expression.
3. Full regular expressions separated by | or by a NEWLINE that match strings that are matched by any of the expressions.
4. A full regular expression that can be enclosed in parentheses ()for grouping.
Be careful using the characters $, *, [, ^, |, (, ), and in full regular expression, because they are also meaningful to the shell. It is
safest to enclose the entire full regular expression in single quotes '... '.
The order of precedence of operators is [], then *?+, then concatenation, then | and NEWLINE.
/usr/xpg4/bin/egrep
The /usr/xpg4/bin/egrep utility uses the regular expressions described in the EXTENDED REGULAR EXPRESSIONS section of the regex(5) manual
page.
The following options are supported for both /usr/bin/egrep and /usr/xpg4/bin/egrep:
-b Precede each line by the block number on which it was found. This can be useful in locating block numbers by context (first
block is 0).
-c Print only a count of the lines that contain the pattern.
-e pattern_list Search for a pattern_list (full regular expression that begins with a -).
-f file Take the list of full regular expressions from file.
-h Suppress printing of filenames when searching multiple files.
-i Ignore upper/lower case distinction during comparisons.
-l Print the names of files with matching lines once, separated by NEWLINEs. Does not repeat the names of files when the pat-
tern is found more than once.
-n Precede each line by its line number in the file (first line is 1).
-s Work silently, that is, display nothing except error messages. This is useful for checking the error status.
-v Print all lines except those that contain the pattern.
/usr/xpg4/bin/egrep
The following option is supported for /usr/xpg4/bin/egrep only:
-x Consider only input lines that use all characters in the line to match an entire fixed string or regular expression to be matching
lines.
The following operands are supported:
file A path name of a file to be searched for the patterns. If no file operands are specified, the standard input is used.
/usr/bin/egrep
pattern Specify a pattern to be used during the search for input.
/usr/xpg4/bin/egrep
pattern Specify one or more patterns to be used during the search for input. This operand is treated as if it were specified as
-epattern_list.
USAGE
See largefile(5) for the description of the behavior of egrep when encountering files greater than or equal to 2 Gbyte ( 2**31 bytes).
See environ(5) for descriptions of the following environment variables that affect the execution of egrep: LC_COLLATE, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
The following exit values are returned:
0 If any matches are found.
1 If no matches are found.
2 For syntax errors or inaccessible files (even if matches were found).
See attributes(5) for descriptions of the following attributes:
/usr/bin/egrep
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |Not Enabled |
+-----------------------------+-----------------------------+
/usr/xpg4/bin/egrep
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWxcu4 |
+-----------------------------+-----------------------------+
|CSI |Enabled |
+-----------------------------+-----------------------------+
fgrep(1), grep(1), sed(1), sh(1), attributes(5), environ(5), largefile(5), regex(5), regexp(5), XPG4(5)
Ideally there should be only one grep command, but there is not a single algorithm that spans a wide enough range of space-time tradeoffs.
Lines are limited only by the size of the available virtual memory.
/usr/xpg4/bin/egrep
The /usr/xpg4/bin/egrep utility is identical to /usr/xpg4/bin/grep -E (see grep(1)). Portable applications should use /usr/xpg4/bin/grep
-E.
23 May 2005 egrep(1)