[HPADM] SUMMARY: Matching/substituting two strings in ksh ??

From: Abramson, Stuart (SAbramson@Wabtec.com)
Date: Tue Nov 25 2003 - 15:32:38 EST


hpux-admins:
 
Thanks to:
 
    Alla Riggs
    Chris Medaglia
    Leon Kazakin
 
Use "set -A" to turn 2 lists of corresponding values into two correspoinding
arrays:

OLD_MPS=/u1001 /u1101 /u1102 /u1201
NEW_MPS=/u2001 /u2101 /u2102 /u2201
 
set -A OLD_ARRAY $OLD_MPS
set -A NEW_ARRAY $NEW_MPS
CNT=${#OLD_ARRAY[@]}
#
(( I=0 ))
while (( I < CNT ))
do
        echo ${OLD_ARRAY[$I]} ${NEW_ARRAY[$I]}
        (( I=I+1 ))
done

        Stuart

 
  _____

From: Kazakin, Leon [mailto:Leon.Kazakin@CIBC.ca]
Sent: Tuesday, November 25, 2003 3:12 PM
To: Abramson, Stuart
Subject: RE: [HPADM] Matching/substituting two strings in ksh ??

set -A arrayname `echo $OLD_MPS`
 
Stuart, are you working with Amdocs application or another telecom sw now?
 
 
Leon

-----Original Message-----
From: Abramson, Stuart [mailto:SAbramson@Wabtec.com]
Sent: Tuesday, November 25, 2003 2:05 PM
To: Hpux-Admin (hpux-admin@dutchworks.nl)
Subject: [HPADM] Matching/substituting two strings in ksh ??

Hpux-admins:

I have two "variable strings" in a ksh script:

        OLD_MPS="/u1001 /u1101 /u1102 /u1201 . . . /uXYYY"
        NEW_MPS="/u2001 /u2101 /u2102 /u2201 . . . /uZQQQ"

I want to go through a mounted directory, and, respectively, for every
occurrence of:
        /u1001 replace it with /u2001
        /u1101 replace it with /u2101

I don't want to replace "/u1" with "/u2". I actually want to replace the
1st occurrence in the "OLD_" list with the 1st occurrence in the "NEW_"
list, the 2nd with the 2nd, the 3rd with the 3rd, etc.

My problem is not the outside loop, but the inside:

        for OMP in $OLD_MPS
        do
                echo $OMP
                # match with $NMP in $NEW_MPS

Can I turn my original variable strings into arrays? Then I could match
OLD_MPS[0] with NEW_MPS[0], etc. How would I do that?

                Stuart

Stuart Abramson | Off: 412/825-1434 | Cell: 412/417-1567 | email:
sabramson@wabtec.com

***** CONFIDENTIALITY NOTE *****
The content contained in this e-mail transmission is legally privileged and
confidential information intended only for the use of the individual or
entity named herein. If the reader of this transmission is not the intended
recipient, you are hereby notified that any dissemination, distribution, or
copying of this transmission is strictly prohibited.

***** CONFIDENTIALITY NOTE *****
The content contained in this e-mail transmission is legally privileged and confidential information intended only for the use of the individual or entity named herein. If the reader of this transmission is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this transmission is strictly prohibited.

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:37 EDT