This will print only lines containing pattern1 and pattern2
Tanks neutronscott.
Got this far too, but pattern1 is in a different line than pattern2 and i would like to print $1 of line $0 found with pattern1 and $2 of line $0 found with pattern2
Hi,
I have to write one script that has to search a list of numbers in certain zipped files.
For eg. one file file1.txt contains the numbers. File1.txt contains 5,00,000 numbers and I have to search each number in zipped files(The number of zipped files are around 1000 each file is 5 MB)
I have... (10 Replies)
Hi
I am trying to search and replace a multi line pattern in a php file using awk.
The pattern starts with
<div id="navbar">
and ends with
</div>
and spans over an unknown number of lines.
I need the command to be a one liner.
I use the "record separator" like this :
awk -v... (8 Replies)
Thanks for giving your time and effort to answer questions and helping newbies like me understand awk.
I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk.
Basically I'd like all lines with ISA sandwiched between... (9 Replies)
Hi all,
I have a file having data:
@HWUSI-EAS1727:19:6:1:3674:984:0:1#GTTAATA
NTTGGGTTTTCT
@HWUSI-EAS1727:19:6:1:3674:984:0:1#GTTA...
NTTGGGTTTTCT
@HWUSI-EAS1727:19:6:1:3674:984:0:1#.....CT
NTTGGGTTTTCT
I want to print everything starting from # till line ends.
can you please help me how... (5 Replies)
Hi all.
I have the following command that is successfully searching for any one of the strings on all lines of a file and replacing it with the instructed value.
cat inputFile | awk '{gsub(/aaa|bbb|ccc|ddd/,"1234")}1' > outputFile
This does in fact replace any occurrence of aaa, bbb,... (2 Replies)
Given:
1,2,whatever,a,940,sot
how can i print from one particular field to the end of line?
awk -F"," '{print $2 - endofline}'
the delimiter just happens to be a comma "," in this case. in other cases, it could be hypens:
1---2---whatever---a---940---sot (4 Replies)
Coins.txt:
gold 1 1986 USA American Eagle
gold 1 1908 Austria-Hungary Franz Josef 100 Korona
silver 10 1981 USA ingot
gold 1 1984 Switzerland ingot
gold 1 1979 RSA Krugerrand
gold 0.5 1981 RSA Krugerrand
gold 0.1 1986 PRC Panda
silver 1 1986 USA Liberty dollar
gold 0.25 1986 USA Liberty... (2 Replies)
Hi,
OS = Solaris
Can anyone advise if there is a one liner to print specific output from a df -k output?
Running df from a command line, it sometimes gives me 2 lines for some volume. By re-directing the output to a file, it always gives 1 line for each.
Below is an example output,... (4 Replies)
Hello Gurus,
I have a file this
Dir Path 1
Connection pool="somename"; "DataSource Name"="DS name"; Password="pwd"; User Id="uid";some other fields
Dir Path2
Password="pwd2"; User id="uid2"; Connection pool="somename2"; "datasource name"="DS name2";some other fields.
Under each dir... (14 Replies)
Discussion started by: sirababu
14 Replies
LEARN ABOUT REDHAT
pcregrep
PCREGREP(1) General Commands Manual PCREGREP(1)NAME
pcregrep - a grep with Perl-compatible regular expressions.
SYNOPSIS
pcregrep [-Vcfhilnrsvx] pattern [file] ...
DESCRIPTION
pcregrep searches files for character patterns, in the same way as other grep commands do, but it uses the PCRE regular expression library
to support patterns that are compatible with the regular expressions of Perl 5. See pcre(3) for a full description of syntax and semantics.
If no files are specified, pcregrep reads the standard input. By default, each line that matches the pattern is copied to the standard out-
put, and if there is more than one file, the file name is printed before each line of output. However, there are options that can change
how pcregrep behaves.
Lines are limited to BUFSIZ characters. BUFSIZ is defined in <stdio.h>. The newline character is removed from the end of each line before
it is matched against the pattern.
OPTIONS -V Write the version number of the PCRE library being used to the standard error stream.
-c Do not print individual lines; instead just print a count of the number of lines that would otherwise have been printed. If sev-
eral files are given, a count is printed for each of them.
-ffilename
Read patterns from the file, one per line, and match all patterns against each line. There is a maximum of 100 patterns. Trailing
white space is removed, and blank lines are ignored. An empty file contains no patterns and therefore matches nothing.
-h Suppress printing of filenames when searching multiple files.
-i Ignore upper/lower case distinctions during comparisons.
-l Instead of printing lines from the files, just print the names of the files containing lines that would have been printed. Each
file name is printed once, on a separate line.
-n Precede each line by its line number in the file.
-r If any file is a directory, recursively scan the files it contains. Without -r a directory is scanned as a normal file.
-s Work silently, that is, display nothing except error messages. The exit status indicates whether any matches were found.
-v Invert the sense of the match, so that lines which do not match the pattern are now the ones that are found.
-x Force the pattern to be anchored (it must start matching at the beginning of the line) and in addition, require it to match the
entire line. This is equivalent to having ^ and $ characters at the start and end of each alternative branch in the regular
expression.
SEE ALSO pcre(3), Perl 5 documentation
DIAGNOSTICS
Exit status is 0 if any matches were found, 1 if no matches were found, and 2 for syntax errors or inacessible files (even if matches were
found).
AUTHOR
Philip Hazel <ph10@cam.ac.uk>
Last updated: 15 August 2001
Copyright (c) 1997-2001 University of Cambridge.
PCREGREP(1)