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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search, replace string in file1 with string from (lookup table) file2? gstuart Shell Programming and Scripting 9 06-08-2009 06:11 AM
replace string in XML with sed chiru_h Shell Programming and Scripting 6 04-09-2008 07:49 PM
replace string sam99 Shell Programming and Scripting 4 03-04-2008 01:39 AM
replace a string melanie_pfefer Shell Programming and Scripting 11 01-17-2008 10:57 AM
Replace string B depending on occurence of string A hemangjani Shell Programming and Scripting 1 12-05-2006 05:10 PM

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 11-20-2008
tuathan tuathan is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 10
Is it possible to replace more the 1 string with one SED?

i want to replace two phrases in text file

originalstringA.1.
blah blah....
originalstringB.1.

got this code so far:

#variables
IP=$1
NO=$2
FS=$3
IS=$4
NN=1
#echo variables
echo ''
echo $IP
echo $NO
echo $FS
echo $IS
echo '****'
echo $NN
#generate files and configure
while [ $NN -le $NO ]
do
cp template.egsinp $IP.$NN.egsinp
sed s/template/$IP.$NN/ <template.egsinp > $IP.$NN.egsinp
#i need something else here that replaces something else and has the same input/output files as the above sed.
echo '****'
NN=$(($NN + 1))
echo $NN
done
#exit
exit
  #2 (permalink)  
Old 11-20-2008
jlliagre jlliagre is offline Forum Advisor  
ɹǝsn sıɹɐlosuǝdo
  
 

Join Date: Dec 2007
Location: Paris
Posts: 1,378
You can replace as many strings as you like with a single sed command by using this syntax:
Code:
sed -e "s/a/b/" -e "s/c/d/" ...
Sponsored Links
Closed Thread

Bookmarks

Tags
sed

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 09:22 AM.


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