HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Text Substitutions based on files
Operating System - HP-UX
1834130
Members
3225
Online
110064
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
03-26-2001 08:12 AM
03-26-2001 08:12 AM
Text Substitutions based on files
I need to be able to search a file for a word then replace some words several lines later. The first word will be a key to finding the values in another file that will be substituted in the later line. I was thinking of using awk but I don't know enough to be able to do this. The specific example is an Oracle based CREATE TABLE statement. First find the line with CREATE TABLE on it and use the 3rd word (table name) to find a value in an external file which has the table size in it. Then scan down to the 'storage' line and make the substitutions. Repeat for every occurrence of CREATE TABLE.
Is awk the right tool? Is there something better?
Is awk the right tool? Is there something better?
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2001 08:33 AM
03-26-2001 08:33 AM
Re: Text Substitutions based on files
You can see sed -e "s/word/Word/g",verify man sed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2001 08:54 AM
03-26-2001 08:54 AM
Re: Text Substitutions based on files
If you are well versed in AWK, you could probabily do it, but I would use PERL instead.
Here is a sample script...
# First read in file with new sizes (each record is TABLE_NAME,NEW_SIZE)
open(INP," while() { chop; ($tbl,$siz)=split(",",$_); $size{$tbl}=$siz; }
close(INP);
open(INP," open(OUT,">newscript");
while()
/^CREATE TABLE (\S+)/ && do { $cretbl=$1; }
/^storage (\S+)/ && do {
if($newsiz=$size{$cretbl}) { s/$1/$newsiz/; }
}
print OUT $_;
}
Here is a sample script...
# First read in file with new sizes (each record is TABLE_NAME,NEW_SIZE)
open(INP,"
close(INP);
open(INP,"
while(
/^CREATE TABLE (\S+)/ && do { $cretbl=$1; }
/^storage (\S+)/ && do {
if($newsiz=$size{$cretbl}) { s/$1/$newsiz/; }
}
print OUT $_;
}
There be dragons...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP