UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 9th, 2005, 09:56 PM
Vaithy_s Vaithy_s is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 3 Vaithy_s User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m
Reputation Power: 0
File manupulation !

Hi Gurus !

1. I wrote a shell script to create a sql script which will create a table with partitions ...
2. I have done it using awk script to create the script ... the script has 507 lines ... but it can increase in future ... so I would like to dynamically modify the script ...

Here is my problem ... at the end of the script :

tablespace sv_test storage(initial 1m next 1m pctincrease 0 maxextents 200),

In the above line I would like to replace the , with )

How can I do this in a shell script ?

Any help is highly appreciated !

Thanks
Vaithy

Reply With Quote
  #2  
Old June 10th, 2005, 09:38 AM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,308 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 2 m 57 sec
Reputation Power: 48
I don't fully understand what you're doing but sub()
takes a regular expression for the first argument, and a replacement string like this
Code:
sub(/$\),/,"))",$0)

Reply With Quote
  #3  
Old June 10th, 2005, 09:48 AM
Vaithy_s Vaithy_s is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 3 Vaithy_s User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m
Reputation Power: 0
Hi Jim,

Thanks for your reply ... Here is what I meant ... I have a file which looks like :

PARTITION sv_03000_p values ('03000')
tablespace sv storage(initial 1m next 1m pctincrease 0 maxextents 200),
PARTITION sv_03001_p values ('03001')
tablespace sv storage(initial 1m next 1m pctincrease 0 maxextents 200),
PARTITION sv_04005_p values ('04005')
tablespace sv storage(initial 1m next 1m pctincrease 0 maxextents 200),
PARTITION sv_04072_p values ('04072')
tablespace sv storage(initial 1m next 1m pctincrease 0 maxextents 200),
PARTITION sv_04221_p values ('04221'))
tablespace sv storage(initial 1m next 1m pctincrease 0 maxextents 200),

In the above text ... in each line there is a , at the end ... I want to replace the , with ) only at the last line of the script.
How can I do that in a shell script ?!

Thanks
Vaithy

Reply With Quote
  #4  
Old June 10th, 2005, 12:31 PM
vgersh99 vgersh99 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 47 vgersh99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 Days 5 h 41 m 53 sec
Reputation Power: 4
Send a message via AIM to vgersh99 Send a message via MSN to vgersh99 Send a message via Yahoo to vgersh99
sed -e '$s/,[ ]*$/)/' yourFile

Reply With Quote
  #5  
Old June 10th, 2005, 02:50 PM
Vaithy_s Vaithy_s is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 3 Vaithy_s User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m
Reputation Power: 0
Quote:
Originally Posted by vgersh99
sed -e '$s/,[ ]*$/)/' yourFile



That worked !!!

Thanks and appreciate your help.

Vaithy

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > File manupulation !


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway