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



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-16-2008
Registered User
 

Join Date: Oct 2007
Posts: 134
output a particular string

Hi experts,

I have many files it contains like below.

GET:SUB:MSI,7601;
RESP:0:SISDN,72030067:MSI,7601:T11,1:T21;
GET:SUB:MSI,7602;
RESP:0:SISDN,72030068:MSI,7602:T11,1:T21;
GET:SUB:MSI,7603;
Resp:1000;
GET:SUB:MSI,7604;
Resp:1000;
GET:SUB:MSI,7605;
RESP:0:SISDN,72030069:MSI,7605:T11,1:T21;


How can i make the output as- In fact, i need to fetch the strings that comes after MSI:7602;
And if Resp:[^0] then "none"
7601
7602
none
none
7605


//purple

Last edited by thepurple; 12-16-2008 at 05:57 AM..
Sponsored Links
  #2 (permalink)  
Old 12-16-2008
Registered User
 

Join Date: Feb 2008
Posts: 131
awk -F: '{ if (substr($4,1,3)=="MSI") { print substr($4,5) } else { if ($1=="Resp" && $2 > 0) { print "none" } } }' input_file
  #3 (permalink)  
Old 12-16-2008
Registered User
 

Join Date: Oct 2007
Posts: 134
great..and many thanks.

just want to know what is the logic behind. a little explanation...
  #4 (permalink)  
Old 12-16-2008
Registered User
 

Join Date: Feb 2008
Posts: 131
-F: --> This declares ":" as the field separator
MSI comes in the 4th word.
If first 3 char of 4th word is "MSI"
print 5th char onwards of 4th word
else
If first word is "Resp" and second word is > 0
print "none"
end if
end if
  #5 (permalink)  
Old 12-16-2008
Registered User
 

Join Date: Oct 2007
Posts: 134
okay..I applogies I missed the point to make u understand.

in fact, i have to only manupulate on- "RESP:0:SISDN,72030067:MSI,7601:T11,1:T21;"

i need to only fetch the MSI from RESP:0.

if Resp:1000 i.e Resp not equal to zero then print None.
Sponsored Links
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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep string and output filename happyv Shell Programming and Scripting 3 11-20-2007 12:16 AM
Converting gettimeoftheday output to string p_aishwarya UNIX for Dummies Questions & Answers 1 10-21-2007 10:13 AM
output only numbers from mixed string nortypig Shell Programming and Scripting 10 08-29-2006 11:30 PM
output string message to pipe princelinux Programming 3 08-18-2006 03:09 AM
output string in reversing order ccp Shell Programming and Scripting 3 11-19-2005 11:05 AM



All times are GMT -4. The time now is 05:44 PM.


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-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0