- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: replacing text - perl, awk....
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
Forums
Discussions
Discussions
Discussions
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
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
07-20-2004 06:09 PM
07-20-2004 06:09 PM
I have many entries like below in a file
/disk1/oracle/HP/hp01.dbf
to
/disk1/oracle/HP/hp01.dbf
/disk2/oracle/HP/hp02.dbf
to
/disk2/oracle/HP/hp02.dbf
I would like to change them as follows
/disk1/oracle/HP/hp01.dbf
to
/disk1_dev/oracle_dev/hp01.dbf
/disk2/oracle/HP/hp02.dbf
to
/disk2_dev/oracle_dev/HP/hp02.dbf
Regards,
Steven
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2004 06:46 PM
07-20-2004 06:46 PM
Solutionmy solution,
Create a script in awk like this:
----- s.awk -------------------
BEGIN {
flag_to=0
FS="/"
OFS="/"
}
/to/ { flag_to=1 }
/disk1/ { if (flag_to==1) $2="disk1_dev" ; flag_to=0}
/disk2/ { if (flag_to==1) $2="disk1_dev" ; flag_to=0}
{ print }
--------------------------------
Then run it:
awk -f s.awk filein > fileout
Hope this helps.
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2004 07:00 PM
07-20-2004 07:00 PM
Re: replacing text - perl, awk....
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2004 07:01 PM
07-20-2004 07:01 PM
Re: replacing text - perl, awk....
these are the datafiles of an Oracle DB. You probably got this list with an SQL statement. How about modifying this SQL statement and "replacing" the second part.
regards,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2004 04:32 AM
07-21-2004 04:32 AM
Re: replacing text - perl, awk....
I have made a mistake, i think you already have seen it.
The statement with /disk2/ is not:
/disk2/ { if (flag_to==1) $2="disk1_dev" ; flag_to=0}
must be:
/disk2/ { if (flag_to==1) $2="disk2_dev" ; flag_to=0}
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2004 05:29 AM
07-21-2004 05:29 AM
Re: replacing text - perl, awk....
So do you want that HP always gone, or just sometimes. If always:
$ perl -pe 's;/oracle/HP;_dev/oracle_dev;' old > new
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2004 06:12 AM
07-21-2004 06:12 AM
Re: replacing text - perl, awk....
sed "s/\/oracle\//\_dev\/oracle_dev\//g" file.txt
regds,
Abdul.