![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 , |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
sed -i '$s/,/)/' zip.20080604.sql |
|
#3
|
|||
|
|||
|
Thanks a lot !
|
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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. |
|||
| Google The UNIX and Linux Forums |