The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > 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
whole word substitution in SED gikay01 Shell Programming and Scripting 7 07-16-2008 01:51 PM
word substitution in unix capri_drm Linux 6 05-14-2008 11:36 AM
How to use sed substitution using a $variable for a line containing a word Sangal-Arun Shell Programming and Scripting 4 08-07-2007 04:09 PM
Can a shell script pull the first word (or nth word) off each line of a text file? tricky Shell Programming and Scripting 5 08-17-2006 03:29 AM
word substitution in csh oprestol Shell Programming and Scripting 1 09-15-2005 08:15 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-04-2008
Registered User
 

Join Date: May 2008
Location: St. Louis
Posts: 74
Last word substitution

Ok this is last question of the day from my side .
I have this file and I want to replace the last letter " , " with " ) " .
The input file is

#cat zip.20080604.sql
CONNECT TO TST103 ;
SET SESSION_USER OPSDM001 ;
SET CURRENT SCHEMA OPSDM001 ;
CREATE VIEW OPSDM001.vw_zip SELECT (
ZIP_CD ,
ZIP_TYP_SRC_CD ,
ZIP_TYP_CD ,
ZIP_ROW_END_DT ,
ZIP_ROW_EFF_DT ,
ZIP_LST_2_CD ,
ZIP_FST_3_CD ,
UPDT_DT WITH
ST_NUM_CD ,
ST_ABBR_CD ,
PST_CNTY_NM ,
PST_CNTY_CD ,
LOAD_DT WITH
HCFA_CNTY_NM ,
HCFA_CNTY_CD ,
CTY_NM ,

Desired output is

#cat zip.20080604.sql
CONNECT TO TST103 ;
SET SESSION_USER OPSDM001 ;
SET CURRENT SCHEMA OPSDM001 ;
CREATE VIEW OPSDM001.vw_zip SELECT (
ZIP_CD ,
ZIP_TYP_SRC_CD ,
ZIP_TYP_CD ,
ZIP_ROW_END_DT ,
ZIP_ROW_EFF_DT ,
ZIP_LST_2_CD ,
ZIP_FST_3_CD ,
UPDT_DT WITH
ST_NUM_CD ,
ST_ABBR_CD ,
PST_CNTY_NM ,
PST_CNTY_CD ,
LOAD_DT WITH
HCFA_CNTY_NM ,
HCFA_CNTY_CD ,
CTY_NM )

Thanks ,
Reply With Quote
Forum Sponsor
  #2  
Old 06-04-2008
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,644
Code:
sed -i '$s/,/)/' zip.20080604.sql
Reply With Quote
  #3  
Old 06-05-2008
Registered User
 

Join Date: May 2008
Location: St. Louis
Posts: 74
Thanks a lot !
Reply With Quote
  #4  
Old 06-09-2008
Registered User
 

Join Date: Mar 2008
Posts: 17
can you please tell me what is the significance of "-i" option in the command.???

i tried to find out but failed to get any info from net.
Reply With Quote
  #5  
Old 06-10-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Some versions of sed allow you to do edits in the file itself, without saving to a temporary file and then moving it back over the original file. Probably your sed doesn't have this option.

Please start a new thread if you have a tangential question.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0