DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 24th July 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
ISO Quartermaster
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 589
Default sh replace string

Let's say i have some input data
$DATA="Some text data that i want to change"

and i want to replace spaces with some other letter, lets say "_"
How can i do that in sh?
Reply With Quote
  #2   (View Single Post)  
Old 24th July 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Default

DATA='Some text data that i want to change'
DATA=$(echo $DATA | tr ' ' _)
Reply With Quote
  #3   (View Single Post)  
Old 24th July 2008
phoenix's Avatar
phoenix phoenix is offline
Risen from the ashes
 
Join Date: May 2008
Posts: 696
Default

Code:
DATA="Some text data that i want to change"
DATA=$( echo $DATA | sed 's|text data|binary crap|' )
echo $DATA
Sorry, didn't see you wanted to just switch one character. tr is best for that.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need a lightweight browser to replace Fx3 TerryP General software and network 15 12th February 2009 10:45 PM
Command to find and replace, but not creating a new file 18Googol2 Programming 4 22nd September 2008 10:28 PM
proxy : replace gif with local gif milo974 OpenBSD General 4 17th July 2008 06:45 AM
improve proxy cache and replace gif MIME milo974 OpenBSD General 1 10th July 2008 12:14 PM
kern.version string in -stable? spiderpig OpenBSD General 1 4th June 2008 01:21 PM


All times are GMT. The time now is 03:37 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick