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
How to get lines in between Patterns? racbern Shell Programming and Scripting 11 04-23-2008 08:28 AM
get the value between 2 patterns minifish Shell Programming and Scripting 11 04-07-2008 03:18 PM
3 patterns in one line bashuser UNIX for Advanced & Expert Users 1 02-16-2008 07:02 PM
search patterns rochitsharma Shell Programming and Scripting 1 02-27-2006 04:14 AM
How to concatenate two strings or several strings into one string in B-shell? fontana Shell Programming and Scripting 2 08-26-2005 12:58 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 07-12-2007
pbsrinivas pbsrinivas is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 141
patterns between strings...

I have a small requirement


How to get patterns between string this way


Input..

05 ABC.
TAGTAG 10 AAA PIC 9
10 BBB PIC X
COMMET 10 CCC COMP PIC 9
05 DEF

I wanted to get all the variable between 05 ABC and next 05 level

out put should be

AAA
BBB
CCC
  #2 (permalink)  
Old 07-12-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
For this specific case, what is your definition of a 'variable'?
  #3 (permalink)  
Old 07-12-2007
pbsrinivas pbsrinivas is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 141
it a cobol code..

TAGTAG 10 AAA PIC 9
10 BBB PIC X
[ ]COMMET 10 CCC COMP PIC 9
05 DEF

1st six chars can be anything followed by some spaces

followed by some 2 digit numeric followed by a varible name... followed COMP or just a PIC
  #4 (permalink)  
Old 07-12-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695

Code:
sed -n '/^05 ABC/,/^05/p' input_file | sed '1d;$d' | \
while read mLine
do
  mVar=`echo $mLine | sed -e 's/.*[0-9]\{2\} \(.*\) .*/\1/' -e 's/ .*//'`
  echo "mVar = "$mVar
done

  #5 (permalink)  
Old 07-12-2007
pbsrinivas pbsrinivas is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 141
thanks...

i was trying with awk '/^05 ABC/,/^05/' input_file

that didnt work

the sed worked ...

thanks
  #6 (permalink)  
Old 07-12-2007
pbsrinivas pbsrinivas is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 141
Small extn to the Previous one

I have Some thing like this

SORT KEY FS-KEY1

###

SORT KEY FS-KEY2
FSKEY3

###

SORT KEY
FS-KEY4

###


Can we get the all the KEY Fields..

It Starts with SORT KEY and the KEY feilds can be in the same line or next line until ### comes
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 12:39 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