The UNIX and Linux Forums  

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
SED Substitution shubhranshu Shell Programming and Scripting 1 11-11-2008 04:50 AM
help with awk substitution daytripper1021 Shell Programming and Scripting 3 09-08-2008 10:58 PM
ksh substitution solea Shell Programming and Scripting 2 08-09-2004 06:30 AM
sed substitution jo_aze UNIX for Dummies Questions & Answers 3 06-23-2002 10:32 PM
substitution supercbw Shell Programming and Scripting 1 06-07-2002 04:07 PM

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

Join Date: Sep 2008
Location: mumbai
Posts: 78
SED Substitution

Hi guys,

Can u please help me to replace (-) with (/) in a file containing no of records using "sed " command in unix.

thanks in advance.

subhendu
  #2 (permalink)  
Old 11-14-2008
labrazil labrazil is offline
Registered User
  
 

Join Date: Sep 2008
Location: San Diego, CA
Posts: 60
I"m not as good as some of the guys here but try this

Code:
sed 's/-/\//' filename > newfile
  #3 (permalink)  
Old 11-14-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 603
Try also with tr ,perl and awk:

Code:
[/tshome/tf01 ]>x="ashdkhsa-sdasldhals-sadakjsh-"
[/tshome/tf01 ]>echo $x | tr "-" "/"
ashdkhsa/sdasldhals/sadakjsh/
or,
Code:
perl -ne 's/-/\//;print;' filename
or,

Code:
[/tshome/tf01 ]>echo $x | awk '{gsub(/-/,"/",$0); print; }'
ashdkhsa/sdasldhals/sadakjsh/
  #4 (permalink)  
Old 11-14-2008
subhendu81 subhendu81 is offline
Registered User
  
 

Join Date: Sep 2008
Location: mumbai
Posts: 78
hi guys,

how can i convert multiple spaces to single space using sed in unix.

thanks in advance.

subhendu
  #5 (permalink)  
Old 11-14-2008
labrazil labrazil is offline
Registered User
  
 

Join Date: Sep 2008
Location: San Diego, CA
Posts: 60
how many spaces are you talking about?
you can use any one of the methods above.

I would try this:

Code:
sed 's/          / /' filename
in addition, read through sed manual

Code:
man sed
they have lots of information and examples.
  #6 (permalink)  
Old 11-14-2008
paresh n doshi paresh n doshi is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 38
Is this a homework or sth?

try this,
tr -s " " < filename > outfile
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 08:36 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