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
awk,nawk,sed, delimiter |~| knijjar Shell Programming and Scripting 7 02-19-2008 02:38 AM
replace the last delimiter jisha Shell Programming and Scripting 4 01-28-2008 06:26 AM
Cut date using y hat as delimiter tekster757 UNIX for Advanced & Expert Users 1 07-31-2007 02:14 PM
\r as delimiter in cut shweta_d Shell Programming and Scripting 5 06-07-2007 09:18 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-14-2007
panknil panknil is offline
Registered User
  
 

Join Date: Apr 2007
Location: Kolkata
Posts: 83
Question Replacement of Delimiter

Dear all,
i have a proble.
in my input file i have records with delimiter like

aa-------bb------cc--vghjav---ef----kjd
dj--------ih------yy--ujdjkkl---dd----jid

now i want to replace the delimiter "-" with "~"
i have used a command i.e
cat FILENAME | tr "-" "~" >> Newfile

this command replacing the input delimiter one by one like

aa~~~~~~~bb~~~~~~cc~~vghjav~~~ef~~~~kjd
dj~~~~~~~ih~~~~~~yy~~ujdjkkl~~~dd~~~~jid

but the output i want is

aa~bb~cc~vghjav~ef~kjd
dj~ih~yy~ujdjkkl~dd~jid

like this

can any one please help me out regarding this problem?

Regards,
Pankaj
  #2 (permalink)  
Old 05-14-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,416
Code:
sed 's/--*/~/g' FILENAME > NewFile
Jean-Pierre.
  #3 (permalink)  
Old 05-14-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
Code:
awk '{gsub("-+","~");print}' file    > newfile
  #4 (permalink)  
Old 05-14-2007
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 704
Hi.
Code:
       -s, --squeeze-repeats
              replace each input sequence of  a  repeated  character  that  is
              listed in SET1 with a single occurrence of that character

-- excerpt from man tr
cheers, drl
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 11:50 PM.


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