LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-15-2018, 02:34 PM   #1
anweshbabu
LQ Newbie
 
Registered: Jul 2018
Posts: 3

Rep: Reputation: Disabled
Shell Script to read all the lines from the specified string until an unmatched string


Hi Folks,

I need your your help to generate a script
[12/06/2011 02:44 IST]thread 000 debug> thread1233-DP122222<soap-envelope><soqp-header>abcd</soap-header><bookticketsRequest><FlightNo>12122</FilghtNo><Price>$22</Price></bookticketsRequest></soap-envelope>
error message abcdjjj com.flight.tickets
[12/06/2011 02:44 IST]thread 000 debug> thread1233-DP122222
<soap-envelope>
<soap-header>abcd</soap-header>
<bookticketsRequest>
<FlightNo>12122</FilghtNo>
<Price>$22</Price>
</bookticketResponse>
</soap-envelope>
[12/06/2011 02:44 IST]thread 000 debug> thread1233-DP122223<soap-envelope><soqp-header>abcd</soap-header><bookticketsRequest><FlightNo>12122</FilghtNo><Price>$22</Price></bookticketsRequest></soap-envelope>
error message abcdjjj com.flight.tickets
[12/06/2011 02:44 IST]thread 000 debug> thread1233-DP122223
<soap-envelope>
<soap-header>abcd</soap-header>
<bookticketsRequest>
<FlightNo>12122</FilghtNo>
<Price>$22</Price>
</bookticketResponse>
</soap-envelope>

[12/06/2011 02:44 IST]thread 000 debug> thread1233-DP122224<soap-envelope><soqp-header>abcd</soap-header><bookticketsRequest><FlightNo>12122</FilghtNo><Price>$22</Price></bookticketsRequest></soap-envelope>
error message abcdjjj com.flight.tickets
[12/06/2011 02:44 IST]thread 000 debug> thread1233-DP122224
<soap-envelope>
<soap-header>abcd</soap-header>
<bookticketsRequest>
<FlightNo>12122</FilghtNo>
<Price>$22</Price>
</bookticketResponse>
</soap-envelope>



I want to read all the highlated text lines with reference id DP122223
 
Old 07-15-2018, 02:44 PM   #2
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 2,230

Rep: Reputation: 701Reputation: 701Reputation: 701Reputation: 701Reputation: 701Reputation: 701Reputation: 701
What have you already tried? Are you restricted to using a shell script?
 
Old 07-15-2018, 03:16 PM   #3
anweshbabu
LQ Newbie
 
Registered: Jul 2018
Posts: 3

Original Poster
Rep: Reputation: Disabled
Iam new to scripting. I tried in many but i didn't find the solution.
My Algorithm is
1.Run the script giving Arguments DP122223
2.read argument as variable
3.from the position of DP122223 in the log using awk compare the argument if it is true

4.read line. Increment.. so on until awk! =given argument
5.Break
 
Old 07-15-2018, 04:39 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 20,839

Rep: Reputation: 5156Reputation: 5156Reputation: 5156Reputation: 5156Reputation: 5156Reputation: 5156Reputation: 5156Reputation: 5156Reputation: 5156Reputation: 5156Reputation: 5156
Quote:
Originally Posted by anweshbabu View Post
Iam new to scripting. I tried in many but i didn't find the solution.
Ok...so why don't you post the 'many' that you tried?? Read the "Question Guidelines" link in my posting signature. We are happy to help you, but we are NOT going to write scripts for you.
Quote:
My Algorithm is
1.Run the script giving Arguments DP122223
2.read argument as variable
3.from the position of DP122223 in the log using awk compare the argument if it is true
4.read line. Increment.. so on until awk! =given argument
5.Break
Sounds logical; many bash scripting examples on how to do each part of this. You should have no trouble putting a trial script together. Post it here if you get stuck
 
Old 07-15-2018, 06:09 PM   #5
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,514

Rep: Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000
If you know what your objective is, why don't you try to do that with a script. If it doesn't work right away, then ask for help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i am not able to concatenate both the string in shell script as below string spatil20 Linux - Newbie 16 04-24-2016 03:59 AM
Shell script to find a string and print x lines before and y lines after the string igorza Linux - Newbie 6 04-18-2013 05:31 PM
Shell scripting - Getting just directory string from file path string? arashi256 Programming 5 10-16-2009 09:21 AM
read string after specific string from a text file using C++ programing language badwl24 Programming 5 10-08-2009 06:41 AM
Shell Script: Delete lines til string found or until particular string. bhargav_crd Linux - General 3 12-21-2007 12:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration