Script to match a pattern and print only the pattern and after that
Hi,
I am writing a shell script to parse some files, and gather data.
The data in the files is displayed as below.
I have tried using awk and cut, bu the position of these values keep changing, so I can use awk and split it into columns.
The value before the ":' is always constant, the value in the brackets only keep changing.
I need an option which prints in the following manner based on what is being grepped.
if xyz: is grepped it should print
(OR)
if abz: is grepped it should print
Please help
Thanks
Last edited by Scrutinizer; 03-01-2013 at 06:51 AM..
Reason: code tags
I have one more question. I also need to be able to compare the values in the same line for example
it should be a one liner and it should be able to compare the value in the brackets for "xyz:" and "abz:" and if it is the samee then it should print "qrt: [2312]"
In the above lines the output should be only "qrt: [2312]" as that is the only line with the matching value in the bracket of "xyz:" and "abz:".
The positions of this variable keep changing in the same line, so I cannot use the divide by columns.
Last edited by Scrutinizer; 03-01-2013 at 06:52 AM..
Reason: code tags
I'm curious: why should it be a one-liner? Is there some length limit? Because, technically, you can convert any large, multi-line awk script into a one liner by simply deleting the newline bytes.
What should the script output if qrt: does not match the other two? Are these abc: xyz: qrt: values input parameters or hard-coded into script? Can you should some example input, script parameters and required output?
this condition is part of a much larger script, Initially I have used the following condition, bu there have been changes int he file format where the values are not specific to a column, so this is not working.
I hope this info helps.
Thanks
---------- Post updated 02-28-13 at 12:51 PM ---------- Previous update was 02-27-13 at 01:40 PM ----------
can some one please help me with the second question?
Thanks
Last edited by Franklin52; 02-28-2013 at 03:13 AM..
Reason: Please use code tags for data and code samples
The intended result should be :
PDF converters
'empty line'
gpdftext and pdftotext?xml version="1.0"?>
xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters
gpdftext and pdftotext</note-content>... (9 Replies)
Hello Experts , require help . See below output:
File inputs
------------------------------------------
Server Host = mike
id rl images allocated last updated density
vimages expiration last read <------- STATUS ------->... (4 Replies)
Hi,
I want to print the lines from file1 which has the matching pattern from file2 in linux.
file1 data is below
-----------------
CACA|1234
CA|2345
file2 data is below
-----------------
CA
NC
TX
Now I want to print the lines from file1 for the values present in file2.
... (5 Replies)
I have
2013-06-11 23:55:14 1Umexd-0004cm-IG <= user@domain.com
I need sed/awk operation on this, so that it should print the very next pattern only after the the pattern mach <=
ie only print user@domain.com (7 Replies)
Hi experts , im new to Unix,AWK ,and im just not able to get this right.
I need to match for some patterns if it matches I need to print the next few words to it.. I have only three such conditions to match… But I need to print only those words that comes after satisfying the first condition..... (2 Replies)
Hi,
I am writing a shell script to parse some files, and gather data.
The data in the files is displayed as below.
.......xyz: abz: ......qrt: ....
.......xyz: abz: ......qrt: ...
I have tried using awk and cut, but the position of these values keep changing, so I wasn't able to get... (2 Replies)
Hi,
I know how to use awk to search some expressions like five consecutive numbers, , this is easy.
However, how do I make awk print the pattern that is been matched?
For example:
input: usa,canada99292,japan222,france59664,egypt223
output:99292,59664 (6 Replies)
Hi
I have a file (say 'file1')and I want to search for a first occurence of pattern (say 'ERROR') and print ten lines in the file below pattern. I have to code it in PERL and I am using Solaris 5.9.
I appreciate any help with code
Thanks
Ammu (6 Replies)