![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. |
|
||||
|
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) |
|
||||
|
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} '` |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|