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 Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replace special characters in multiple files - perl RMSoares Shell Programming and Scripting 1 09-01-2009 06:09 PM
Find and replace special characters in a file sujithchandra UNIX for Dummies Questions & Answers 2 10-24-2008 06:59 AM
Help with find and replace w/string containing special characters CAGIRL UNIX for Dummies Questions & Answers 4 10-07-2008 07:13 PM
Problem with awk while handling special charaters subin_bala Shell Programming and Scripting 4 07-25-2008 06:00 AM
Replace Special characters in a file solai UNIX for Dummies Questions & Answers 1 07-13-2006 10:36 AM

Reply
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 4 Weeks Ago
drtabc drtabc is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 3
replace word with special charaters

I have input file called file1 with characters that have \\ in it.
I cannot change input file, because it is generated earlier in script.
Now would like to replace string on line in file called bfile with output from file1
I have been using sed command.
Code:
$cat file1
pc//6sPxp==
$ cat scr1
#!/bin/ksh
BC=`cat file1`
sed -e "s/State/$BC/g" bfile
$ ./scr1
sed: command garbled: s/State/pc//6sPxp==/g

Last edited by pludi; 4 Weeks Ago at 04:44 PM.. Reason: code tags, please...
  #2 (permalink)  
Old 4 Weeks Ago
hexram hexram is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 4
You should use another character as a delimiter in sed command:
Code:
sed -e "s%State%$BC%g" bfile
instead of:
Code:
sed -e "s/State/$BC/g" bfile
for example... You may choose a character that is not in the file whose contents is to be changed, though; in fact, this is the explanation of the error message that you include in your request.
  #3 (permalink)  
Old 4 Weeks Ago
drtabc drtabc is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 3
Yes, that worked!
Thank you hexram!
I thought I was going to have to write a sub routine to analyze file1 character by character.
I not sure what other delimiter I could use? Ok read man page. "Any character other than backslash or newline can be used instead of a slash to delimit the RE and the replacement."
I will change code to look at output from generated file1 and make changes to sed command, if file1 has /, %, $, etc.... in it.
  #4 (permalink)  
Old 4 Weeks Ago
drtabc drtabc is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 3
Ok
Will do this next post, sorry.
Reply

Bookmarks

Tags
replace characters special

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:51 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