I need a one liner because it is part of a bigger script as I have mentioned. I am not sure what do you mean by homework. I am writing this script to gather a lot of different variables, and this is just one of the variable.
A solution and the number of lines in the code is also equally important to me as I will be filtering a lot of other parameters before i come to this part of comparison, and also do a lot more filtering and calculation.
Earlier when the position of the variables in the log files weren't changing so i used to use a simple awk comparison like below,
I am not an expert in awk, so I am asking help on this.
And finally sorry for starting another thread, I wasn't sure if it has to be one question in each thread, so I started a new one.
Most of the time, I search and try for solutions from the existing threads, but i couldn't find anything close to my problem and I really need some help in getting this solution.
Thanks
Last edited by Scrutinizer; 03-01-2013 at 06:52 AM..
Reason: code tags
The position of "qrt", "xyz" and "abc" would change. It can be in any order.
if the input is
then the output should be null, as I want the comparison of the value in the bracket of only xyz and abz. and print qrt only if it is the same.
In your example the values in the brackets of xyz and abz are not equal so, it should not return anything
if the input is
then the output should be qrt:[2312]. As the values int he brackets of abz is equal to the value in the brackets of xyz.
The strings "xyz:", "abz:" and "qrt:" always remain the same only the values in the bracket keep changing.
I hope this makes it more clear.
Thanks
Last edited by Scrutinizer; 03-01-2013 at 06:53 AM..
Reason: code tags
The solution offered above works perfectly on all examples you provided so far. Put it into a function if you aim for readability of the main script.
BTW, even if sensibly (!) collapsed to a one liner, it will work ...
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)