Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Shell Scripting help


Login or Register to Reply

 
Thread Tools Search this Thread
# 15  
It's all doable in perl.
Code:
perl -lne 'm#pName="vin"# and @dt=m#dateTime="(.*?)"# and @mis=m#mis>(.*?)</.*?mis>#g and print $dt[0], " , ", join(" & ", @mis)' temp2.txt

One can store the output of a match in an array. And when printing the array let the join function insert separators.
This User Gave Thanks to MadeInGermany For This Post:
# 16  
To also fulfill your earlier requirement, here is an addon that also joins multiple <seg> values:
Code:
perl -lne 'm#pName="vin"# and @dt=m#dateTime="(.*?)"# and @mis=m#mis>(.*?)</.*?mis>#g and @seg=m#seg>(.*?)</.*?seg>#g and print $dt[0], ",", join(" & ", @mis), ",", join(" & ", @seg)' temp2.txt

Now I think you should be able to further extend this yourself...
This User Gave Thanks to MadeInGermany For This Post:
# 17  
Quote:
Originally Posted by MadeInGermany
To also fulfill your earlier requirement, here is an addon that also joins multiple <seg> values:
Code:
perl -lne 'm#pName="vin"# and @dt=m#dateTime="(.*?)"# and @mis=m#mis>(.*?)</.*?mis>#g and @seg=m#seg>(.*?)</.*?seg>#g and print $dt[0], ",", join(" & ", @mis), ",", join(" & ", @seg)' temp2.txt

Now I think you should be able to further extend this yourself...
Many thanks for this.

I was trying to grep this payload as well using perl but not able to get the expected result.

Code:
<l:ev dateTime="2019-06-14 09:30" pName="vin"> <n:mis>222</n:mis><n:seg>sit</n:seg> <Response><a><ErrorD>Err-116</ErrorD></a><a><ErrorD>Err-117</ErrorD></a>><a><ErrorD>Err-116</ErrorD></a></Response> <Logging><a><ErrorD>Err-116</ErrorD></a><a><ErrorD>Err-117</ErrorD></a>><a><ErrorD>Err-118</ErrorD></a></Logging></l:ev>

Here i was expecting this output like ErrorD to come once only for Response section not for Logging section.
Expected Output:
222,sit,Err-116 & Err-117 & Err-118

For this i was trying these but seems not correct.

Code:
perl -lne 'm#pName="vin"# and @dt=m#dateTime="(.*?)"# and @mis=m#mis>(.*?)</.*?mis>#g and @seg=m#seg>(.*?)</.*?seg>#g and  @MError=m#Response.*?>.*?<.*?ErrorD.*?>(.*?)</.*?ErrorD>.*?</.*?Response>#g  and print $dt[0], ",", join(" & ", @mis), ",", join(" & ", @seg)', ",", join(" & ", @MError)' temp2.txt

perl -lne 'm#pName="vin"# and @dt=m#dateTime="(.*?)"# and @mis=m#mis>(.*?)</.*?mis>#g and @seg=m#seg>(.*?)</.*?seg>#g and  @MError=m#ErrorD.*?>(.*?)</.*?ErrorD>#g  and print $dt[0], ",", join(" & ", @mis), ",", join(" & ", @seg)', ",", join(" & ", @MError)' temp2.txt


Thanks,
Nitish

Last edited by nit42; 1 Week Ago at 09:04 PM..
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Perl scripting or shell scripting?
Anna Hussie
i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher?... Web Development
1
Web Development
Shell Scripting vs Perl scripting
Pouchie1
Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with...... What is on Your Mind?
2
What is on Your Mind?
Shell scripting vs Perl scripting
Pouchie1
Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to...... What is on Your Mind?
14
What is on Your Mind?
Call Shell scripting from Perl Scripting.
anupdas
Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this?... Shell Programming and Scripting
2
Shell Programming and Scripting
difference between AIX shell scripting and Unix shell scripting.
haroonec
please give the difference between AIX shell scripting and Unix shell scripting.... Shell Programming and Scripting
2
Shell Programming and Scripting

Featured Tech Videos