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 > Operating Systems > Linux
.
google unix.com



Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do I view a jpeg? dsstamps UNIX for Dummies Questions & Answers 0 05-14-2008 01:25 PM
How to view my IP blowFish@ubuntu UNIX for Dummies Questions & Answers 14 05-09-2008 09:35 AM
view log files sak900354 UNIX for Dummies Questions & Answers 5 06-15-2006 07:26 AM
DBM View schafferm UNIX for Dummies Questions & Answers 1 08-06-2002 04:18 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 05-14-2008
capri_drm capri_drm is offline
Registered User
  
 

Join Date: May 2008
Location: St. Louis
Posts: 78
sed to fix view names

I have a ddl file which have lots of view in it. I want to replace all the existing views with VW_< view name> . I am prefixing VW to existing view name .

For example, In old file grep on view is like this

CREATE VIEW OPSDM001.PROVIDER_MBR_PRI ( MBR_PRI_PROV_SYS_ID, MBR_PRI_COS_PROV_SPCL_CD,
CREATE VIEW OPSDM001.PROVIDER_REF ( REF_PROV_SYS_ID, REF_COS_PROV_SPCL_CD,
CREATE VIEW OPSDM001.PROVIDER_SRVC ( SRVC_PROV_SYS_ID, SRVC_COS_PROV_SPCL_CD,


but after editing , I want the result like this

CREATE VIEW OPSDM001.VW_PROVIDER_MBR_PRI ( MBR_PRI_PROV_SYS_ID, MBR_PRI_COS_PROV_SPCL_CD,
CREATE VIEW OPSDM001.VW_PROVIDER_REF ( REF_PROV_SYS_ID, REF_COS_PROV_SPCL_CD,
CREATE VIEW OPSDM001.VW_PROVIDER_SRVC ( SRVC_PROV_SYS_ID, SRVC_COS_PROV_SPCL_CD,

It could take care of any number of view occurance .
Any help is appreciated ,
Thanks in advance ,
  #2 (permalink)  
Old 05-14-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Something like this should do the job:

Code:
sed 's/\(.*\.\)\(.*\)/\1VW_\2/' file > newfile
Regards
  #3 (permalink)  
Old 05-14-2008
capri_drm capri_drm is offline
Registered User
  
 

Join Date: May 2008
Location: St. Louis
Posts: 78
Thanks Frankiln but its making VW_ changes to all the table names too in the file. I need VW_ only for view names.

If my original file is like this ,

create table opsdm001.dim_date
create view opsdm001.dim_date_view

then i want to change it to

create table opsdm001.dim_date
create view opsdm001.VW_dim_date_view

but with your suggestion, the table name is also prefixed with VW_

Thanks again ,
  #4 (permalink)  
Old 05-14-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Try this:

Code:
sed '/^create view/s/\(.*\.\)\(.*\)/\1VW_\2/' file > newfile
Regards
  #5 (permalink)  
Old 05-14-2008
capri_drm capri_drm is offline
Registered User
  
 

Join Date: May 2008
Location: St. Louis
Posts: 78
Sorry Franklin, that didn't work at all .
  #6 (permalink)  
Old 05-14-2008
capri_drm capri_drm is offline
Registered User
  
 

Join Date: May 2008
Location: St. Louis
Posts: 78
Franklin,
My bad ! You were right. It worked. I was doing change for create view as lower case while in my file its all uppercase .

Thanks a lot !!!

Daya
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:44 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