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
Extract .tgz files that only contain a pattern percivalwcy UNIX for Dummies Questions & Answers 12 08-18-2008 03:19 AM
awk: need to extract a line before a pattern npn35 Shell Programming and Scripting 17 06-29-2008 11:38 PM
Extract Pattern Sequence jaganadh Shell Programming and Scripting 5 12-10-2007 11:06 AM
Extract the Pattern aajan UNIX for Dummies Questions & Answers 6 08-08-2007 05:47 AM
Please help! Sed extract a pattern zhen Shell Programming and Scripting 11 09-18-2006 01:36 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 10-11-2008
gunaah gunaah is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 7
extract a string after a pattern using sed

I have a very large file and each line has a pattern and it is not position specific. I need to extract the string after the pattern

****MI* is the pattern in the red color
12 digit number is the sting value in the green color and it ends with ~

e.g.

5~NM1*IL*1*ARROYO*JESUS****MI*010001990802~N3*11300 WOOD ST*APT J~
***15~NM1*IL*1*HILARIO VALENCIA*ISMAEL****MI*010002846144~N3*9242
***15~NM1*IL*1*SALDANA*NICOLASA****MI*010000817902~N3*12348 N HIGH
*P*18****6***15~NM1*IL*1*CARRILLO*OSCAR****MI*010002858693~N3*8000
5~NM1*IL*1*MENDOZA*KIARA****MI*010001985968~N3*9119 DECOY CT~N4*LA
*18****6***15~NM1*IL*1*NAVARRETTE*JADE****MI*010001670093~N3*5075
5~NM1*IL*1*GARCIA*FERNANDO****MI*010001922131~N3*5811 KAREN PL~N4*
*6***15~NM1*IL*1*RATTERO*JAQUELINE****MI*010001773030~N3*253 E MCK
18****6***15~NM1*IL*1*ROSAS*ALONDRA****MI*010001731780~N3*1326 1/2
18****6***15~NM1*IL*1*RAMOS-HERNANDEZ*ROSALINDA****MI*010002883575
18****6***15~NM1*IL*1*YU*LARRY****MI*010001974928~N3*2817 WENDELL
18****6***15~NM1*IL*1*YU*LARRY****MI*010001974928~N3*2817 WENDELL
***15~NM1*IL*1*SOTO*RAUL****MI*010001882921~N3*1318 NORTH HELM AVE
***15~NM1*IL*1*LINARES*LUIS****MI*010000877519~N3*3489 E MCKINLEY
**6***15~NM1*IL*1*CALDERON*GERARDO****MI*010000744686~N3*1522 AMAD
010001974928~N3*2817 WENDELL AVE~N4*RICHMOND*CA*948041361~DMG*D8*1

cat c2.txt | tr '~' '\n' | grep '****MI'

I am not getting desired result

Pls. help

Thanks
  #2 (permalink)  
Old 10-11-2008
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 3,002
please post in the appropriate forum for your question! moved to shell programming. this is also a dup of Grep & print

thread closed!

Last edited by DukeNuke2; 10-11-2008 at 04:54 PM..
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 01:17 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-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0