- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- change of a string in different lines
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2008 07:36 AM
тАО09-03-2008 07:36 AM
i have a dynamic file, which is generated by an ORACLE tool. Now i want to change a string, which begins with TABLESPACE following by "Name of Tablespace". The name of the new TABLESPACE is static.
Example: TABLESPACE new : APPLI
old: TABLESPACE "AMITTEL"
new: TABLESPACE "APPLI"
this is easy but i have following situation:
REM 255 TABLESPACE "AMITTEL" LOGGING PARTITION BY RANGE ("FIRMA" ,
REM "BON_DATZT" ) (PARTITION "FA_00_WO_0ANF" VALUES LESS THAN ('00',
REM 255 STORAGE(INITIAL 262144 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE
REM "APPLI" LOGGING NOCOMPRESS, PARTITION "FA_00_WO_200801" VALUES LESS
i attach the whole file.
i don't know, how to change it over different lines ...
regards,tom
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2008 08:39 AM
тАО09-03-2008 08:39 AM
Re: change of a string in different lines
I'd recommend making this into a script and make the tablespace name an input variable taken on the command line like $1
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2008 09:16 AM
тАО09-03-2008 09:16 AM
SolutionTry this:
# perl -00 -pe 's/TABLESPACE "AMITTEL"/TABLESPACE "APPLI"/gms;s/(TABLESPACE\s*REM\s*)"AMITTEL"/$1"APPLI"/gms' file
...and if you want to update your "file" in-place, simply change '-pe' to '-pi.old -e' as:
# perl -00 -pi.old -e 's/TABLESPACE "AMITTEL"/TABLESPACE "APPLI"/gms;s/(TABLESPACE\s*REM\s*)"AMITTEL"/$1"APPLI"/gms' file
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2008 05:03 PM
тАО09-03-2008 05:03 PM
Re: change of a string in different lines
# perl -0 -pe 's/TABLESPACE(\s+|\s*REM\s*)"\w+/TABLESPACE$1"appli/g' old.tmp > new.tmp
The "/m" for "Treat string as multiple lines." is not for this me thinks.
The critical part here is : (\s+|\s*REM\s*)
This matches with just whitespace OR whitespace surrounding REM and remimbers either in $1 to be used in the substitution.
But typically the tablespace name(s) between their double quotes are unique enough. If so the perl solution could just be:
perl -pe 's/"AGROSS"|"AMITTEL"|"APPLI"/"test"/' old .tmp > new.tmp
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-04-2008 12:38 AM
тАО09-04-2008 12:38 AM
Re: change of a string in different lines
thank your for perfect solutions: i choice one example and extented it like :
NEW_TBLSP="APPLIU"
echo $NEW_TBLSP
export NEW_TBLSP
perl -00 -pi.old -e 's/TABLESPACE "[A-Z]*"/TABLESPACE "$ENV{"NEW_TBLSP"}"/gms;s/(TABLESPACE\s*REM\s*)"[A-Z]*"/$1"$ENV{"NEW_TBLSP"}"/gms' file
it works perfect.
thank to all
Tom