The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
extracting a set of strings from a text file Deanne Shell Programming and Scripting 2 09-21-2007 12:31 AM
Extracting information from text fields. spindoctor UNIX for Dummies Questions & Answers 24 06-09-2007 02:17 PM
extracting last paragraph from a text uvrakesh Shell Programming and Scripting 1 04-24-2007 06:36 AM
searching text question BG_JrAdmin UNIX for Dummies Questions & Answers 4 05-29-2005 09:52 AM
Searching for text in files GandalfWhite Linux 2 01-21-2004 01:26 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-06-2007
sjday sjday is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 9
Searching and extracting text from output

I have the following output which I need to obtain the values for "Next Seq is xxx" and "Last Seq is xxx" and "Pending count is xxx". You will notice that the number of words prior to that value can be variable hence the reason for asking this question.

LINECMD> Line /xxx///ABC9_SND is UP. Snd-Enabled. Tracing enabled. Line information: "STARTNG-Up Cmd" Next seq is 1 Last seq is 0 Processed count is 0 Pending count is 4 Line /xxx///ABC9_SND is connected to: /xxx///ABC9_OUTQ
LINECMD> Line /xxx///abc0_SND is UP. Snd-Enabled. Tracing enabled. Line information: "STARTNG-Up Cmd" Next seq is 1 Last seq is 0 Processed count is 0 Pending count is 4 Line /xxx///RGW0_SND is connected to: /xxx///XYW0_OUTQ
LINECMD> Line /xxx///BCDPRT is UP. Line information: "209134" Next seq is 8 Last seq is 7 Processed count is 7 Pending count is 0 ACK'ing is not enabled Line /xxx///BCDPPRT is connected to: /xxx///EXCPPRTQ /xxx/MTRANS//EXCPPRTQ
LINECMD> Line /xxx///XYW_POST_01 is UP. Line information: "UP POSTING LOGGED IN" Next seq is 10 Last seq is 9 Processed count is 9 Pending count is 0 Line /xxx///XYW_POST_01 is connected to: /xxx///XYW_AUTQ

I have looked at using awk for it but I am unable to get it to work with the variable position. Any assitance in getting this resolved would be appreicated.
  #2 (permalink)  
Old 12-06-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,957
to start with

Code:
sed 's/.*\(Next seq is \)\([0-9]*\).*/\1\2/' a
  #3 (permalink)  
Old 12-06-2007
sjday sjday is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 9
my current code

That didn't give me the results I was after. Heres a copy of something that appears to work but I am sure it could be done better

echo 'LINECMD> Line ////AT_VLD is UP. Line information: "CONNECTED: 1, 2, 3" Next seq is 8880 Last seq is 0 Processed count is 0 Pending count is 0'|awk 'match($0,"Next seq is [0-9]*") {print substr($0,RSTART, RLENGTH)}'|awk '{ print $4} '


result = 8880 # What I want to see

Now that I have obtained that how can I obtain the information for the line information i.e. "CONNECTED: 1, 2, 3" or "UP"(depending on what is returned)
  #4 (permalink)  
Old 12-07-2007
sjday sjday is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 9
My final solution

Just in case anyone is interested here is my final code that worked as I was expecting it

LINE_INFO=`echo $STATUS|awk 'match($0,"Line information: \".\*\" ") {print substr($0,RSTART, RLENGTH)}'|awk '{ print $3,$4,$5,$6,$7} '`
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0