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
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-04-2008
Registered User
 

Join Date: May 2008
Location: St. Louis
Posts: 70
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 (permalink)  
Old 06-04-2008
reborg's Avatar
Administrator
 
Join Date: Mar 2005
Location: Ireland
Posts: 3,502
Code:
sed -i '$s/,/)/' zip.20080604.sql
Reply With Quote
  #3 (permalink)  
Old 06-05-2008
Registered User
 

Join Date: May 2008
Location: St. Louis
Posts: 70
Thanks a lot !
Reply With Quote
  #4 (permalink)  
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 (permalink)  
Old 06-10-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,046
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 UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:01 PM.


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

Content Relevant URLs by vBSEO 3.2.0