The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Pattern Matching problem in UNIX maxmave Shell Programming and Scripting 2 06-03-2008 01:19 AM
pattern matching problem namishtiwari Shell Programming and Scripting 2 05-23-2008 07:33 AM
problem with CASE pattern matching gummysweets Shell Programming and Scripting 2 03-18-2008 11:30 AM
pattern matching problem rein Shell Programming and Scripting 8 10-26-2007 11:44 PM
negate * with in pattren matching... pbsrinivas Shell Programming and Scripting 7 06-11-2007 09:30 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-26-2006
pbsrinivas pbsrinivas is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 141
Problem with pattren Matching

I have a set of programs and there coressponding MAPSETs
i tried grep on the all the programs and got the following out put
from this i want to extract only the Program Name and Mapset name {i.e. the word in (' ') after MAPSET }

There or some cases where u have no ( after MAPSET that need to be ignored

input :

A:003150 EXEC CICS RECEIVE MAPSET ('M00DA01') MAP ('DA0001 ') P00DA01
A:004370 EXEC CICS SEND MAPSET ('M00DA01') P00DA01
B:002060 MAPSET ('M0201A')
B:005280 MAPSET ('M0201A')
C:002060 MAPSET ('M0202A')
F: *** M0601A - DEAL INCEPTION MAPSET
G: MAPSET('M0601A')
G: MAPSET('M0601A')
E: MAPSET ('M0602A')
G: MAPSET ('M0601A')
K:011070 MAPSET('M0607A')
L:014510 MAPSET('M0605A')
M:000189 EXEC CICS RECEIVE MAP('M1101A1') MAPSET('M1101A') END-EXEC.
M:000695 EXEC CICS SEND MAP('M1101A1') MAPSET('M1101A')
O: * MAPSET -> M1214A / MAP(S) -> M1214A1 *


Output :


A: M00DA01
B: M0201A
C: M0202A
G: M0601A
E: M0602A
K: M0607A
L: M0605A
M: M1101A
  #2 (permalink)  
Old 11-27-2006
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
I'm sure there must be a cleaner way to do this, but a sed expert I'm not - I did enjoy dusting off the old regexp reference, though.

If you want to sort on field 1 (the A:, B:, etc), change the 'sort -k2' to 'sort -k1'.

Code:
#! /bin/sh

sed -n "/('.*')/p" | \
 sed -e "s/^\(.\:\).*MAPSET *('\([a-zA-Z0-9]*\)'.*$/\1 \2/g" | \
 sort -k2 -u
Assuming it's named "tmp.sh", run it like './tmp.sh <input-file'
  #3 (permalink)  
Old 11-27-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Code:
sed -n -e "s/.*MAPSET *('\([^']*\)'.*/\1/p" | sort -u
  #4 (permalink)  
Old 11-27-2006
pbsrinivas pbsrinivas is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 141
that give only the mapset,It does not give the program name

i wanted some thing like

A: M00DA01
B: M0201A
C: M0202A
G: M0601A
  #5 (permalink)  
Old 11-27-2006
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
vino, I knew that could be done in one line. Here's a slightly-updated version of yours that does the same as my earlier attempt:
Code:
 sed -n -e "s/\(.:\).*MAPSET *('\([^']*\)'.*/\1 \2/p" <input-file | sort -k2 -u
  #6 (permalink)  
Old 11-27-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
one more,

Code:
sed -e "s/.*MAPSET *('//;s/').*//" filename| sed -n '/^M.*/p' | sort -u
  #7 (permalink)  
Old 11-27-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
you can modify vino's solution :

Code:
sed -n -e "s/\(.*\):.*MAPSET *('\([^']*\)'.*/\1: \2/p" filename | sort -u
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 03:50 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