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 > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
from - to delimiter bighippo Shell Programming and Scripting 6 03-13-2008 02:47 AM
replace space with delimiter in whole file -perl meghana Shell Programming and Scripting 11 02-19-2008 09:35 PM
\r as delimiter in cut shweta_d Shell Programming and Scripting 5 06-07-2007 09:18 AM
Replacement of Delimiter panknil Shell Programming and Scripting 3 05-14-2007 07:35 AM
replace delimiter : with '\001' in unix data file spandu Shell Programming and Scripting 4 04-25-2006 08:51 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-28-2008
jisha jisha is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 144
Arrow replace the last delimiter

hi,
i have a file of the below format:
WA| 3|52|Waste |
PW| 3|53|Promotion Waste |
BR| 3|54|Breakage |
TH| 3|55|Theft |
IC| 3|56|Insurance Claim |


I want to replace the last delimiter | by using sed command ...can u please help me witht this

Thanks in advance
Js
  #2 (permalink)  
Old 01-28-2008
quintet quintet is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 94
sed -e 's/|$//' filename
  #3 (permalink)  
Old 01-28-2008
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Quote:
Originally Posted by jisha View Post
hi,
i have a file of the below format:
WA| 3|52|Waste |
PW| 3|53|Promotion Waste |
BR| 3|54|Breakage |
TH| 3|55|Theft |
IC| 3|56|Insurance Claim |


I want to replace the last delimiter | by using sed command ...can u please help me witht this

Thanks in advance
Js
Replace the last delimiter with what ? Or are you looking to remove it altogether.

Code:
sed -e "s/\(.*\)|/\1/g" input.txt
or

Code:
sed -e "s/\(.*\)|/\1 DELIMITER_REPLACED_WITH_THIS_STRING/g" input.txt
  #4 (permalink)  
Old 01-28-2008
jisha jisha is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 144
Thanks a lot vino .
I wanted to replace the last with space ... Sorry for not mentioning

Js
  #5 (permalink)  
Old 01-28-2008
jisha jisha is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 144
thanks a lot for the answer quintet
It worked out perfect
Js
Sponsored Links
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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