Hi
i need a help for making a script whch can print next line if it matches a particular word
like file1 have
ename Mohan
eid 2008
ename Shyam
eid 345
if scipt got Mohan it will print next line (eid 2008)
pls help me .......:) (2 Replies)
Hi All,
I would like my code to be able to print out the whole line if 1st field has a dot in the number. Sample input and expected output given below.
My AWK code is below but it can;t work, can any expert help me ?
Thanks in advance.
{if ($1 ~ /*\.*/) { print $0 }}
Input:
... (2 Replies)
Hi Folks!
im printing all lines where the characters in position 270-271 match 33|H1|HA|KA|26 so i came up with this
#!/bin/bash
array=(33 H1 HA KA 26 )
for i in "${array}"
do
#echo $i
awk '{ if (substr($0,270,2)~'/$i/') print; }' $1 >> $1.temp
done
It works fine . but... (2 Replies)
Good day,
I have a list of regular expressions in file1. For each match in file2, print the containing line and the line after.
file1:
file2:
Output:
I can match a regex and print the line and line after
awk '{lines = $0} /Macrosiphum_rosae/ {print lines ; print lines } '
... (1 Reply)
I have a file and when I match the word "initiators" in the first column I need to be able to print the rest of the columns in that row. This is fine for the most part but on occasion the "initiators" line gets wrapped to the next line. Here is a sample of the file.
caw-enabled ... (3 Replies)
Hi,
I could only find examples to print line before/after a match, but I'd need to print line after two separate lines matching.
E.g.: From the below log entry, I would need to print out the 1234. This is from a huge log file, that has a lot of entries with "CLIENT" and "No" entries (+ other... (3 Replies)
Hi
I want to extend following command so that on the basis of "Branch: ****" on the third line I can grep and print name of the file on the first line.
cat .labellog.emd | grep DA2458A7962276A7E040E50A0DC06459 | cut -d " " -f2 | grep -v branch_name | xargs -I file <command to describe> file
... (1 Reply)
Der colleagues,
4 days I am trying to solve my issue and no success..
Maybe you can give me a clue how to achieve what I need..
So I have two files.
file1 example:
1_column1.1 1_column2.1 aaa 1_column4.1
1_column1.2 1_column2.2 ttt 1_column4.2
1_column1.3 1_column2.3 ... (10 Replies)
datafile:
2017-03-24 10:26:22.098566|5|'No Route for Sndr:RETEK RMS 00040 /ZZ Appl:PF Func:PD Txn:832 Group Cntr:None ISA CntlNr:None Ver:003050 '|'2'|'PFI'|'-'|'EAI_ED_DeleteAll'|'EAI_ED'|NULL|NULL|NULL|139050594|ActivityLog|
2017-03-27 02:50:02.028706|5|'No Route for... (7 Replies)
Discussion started by: SkySmart
7 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)