![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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... |
|
||||
|
You should use another character as a delimiter in sed command:
Code:
sed -e "s%State%$BC%g" bfile Code:
sed -e "s/State/$BC/g" bfile |
|
||||
|
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. |
![]() |
| Bookmarks |
| Tags |
| replace characters special |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|