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
replacing string in an XML file subin_bala Shell Programming and Scripting 2 06-03-2008 07:14 AM
Replacing Last occurance of & from a string vivekshady Shell Programming and Scripting 1 05-13-2008 08:15 PM
problem in replacing a string ragavhere Shell Programming and Scripting 9 05-02-2008 09:02 AM
Replacing string in files mohan705 Shell Programming and Scripting 2 08-29-2007 01:27 AM
string replacing priya_9patil Shell Programming and Scripting 1 11-03-2006 12:05 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 03-18-2007
Viken Viken is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 4
Problem replacing the string

I have three files that the string inside it I want to replace
so my code will be

#!/bin/bash
read -p "please input the old string:" string1
read -p "please input the new string:" string2
sed -i "s/string1/string2/g" *.c

but the problem is.. the string that I want to replace can't be changed
is that possible the code that i wrote is wrong ?
there is have any solution ?

thank you
  #2 (permalink)  
Old 03-18-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,530
string1 and string2 are variables. when you call variables, put $. something like this
eg
Code:
sed -i "s/$string1/$string2/g" *.c
  #3 (permalink)  
Old 03-18-2007
Viken Viken is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 4
Thank you very much
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 02:43 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