Sponsored Content
Top Forums Shell Programming and Scripting Trouble with sed and substituting a string with special characters in variable Post 302649889 by ampsys on Friday 1st of June 2012 08:20:09 AM
Old 06-01-2012
Thanks for your reply, bakunin. Sorry it wasn't more clear, but in the OP, I was trying to convey that $marker was the string itself that I wanted to replace (VENDORLIST), and $markerrepl was the cat(ed) results of the formatted file I gave an example of:

Code:
                                                          ITEM{
                                                          LABEL = Panasonic Corporation of N.A.
                                                          VALUE = Panasonic Corporation of N.A.
                                                          }
                                                           ITEM{
                                                          LABEL = NewWave Technologies, Inc.
                                                          VALUE = NewWave Technologies, Inc.
                                                          }
                                                           ITEM{
                                                          LABEL = Kyocera Doc Solutions of America, Inc.
                                                          VALUE = Kyocera Doc Solutions of America, Inc.
                                                          }
                                                          ITEM{
                                                          LABEL = Ingram Micro, Inc.
                                                          VALUE = Ingram Micro, Inc.
                                                          }

Anyway, I guess we can close this. I gave up on sed and trying to figure out how to escape the special characters and just used perl to accomplish the desired result.

Thanks again for your help!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Substituting with value of variable in Sed

Hi, I have a program in which i have to substitute a TAG in a file with the value of a variable. Code Snippet: ---------------- myvar=1234 sed 's/_TAG_/$myvar/' infile outfile When I run this command, the _TAG_ in the "infile" is substituted with "$myvar" but NOT the value "1234"... (1 Reply)
Discussion started by: jyotipg
1 Replies

2. Shell Programming and Scripting

Add string after another string with special characters

Hello everyone, I'm writing a script to add a string to an XML file, right after a specified string that only occurs once in the file. For testing purposes I created a file 'testfile' that looks like this: 1 2 3 4 5 6 6 7 8 9 And this is the script as far as I've managed: ... (2 Replies)
Discussion started by: heliode
2 Replies

3. Shell Programming and Scripting

Variable Manimpulation - special characters

Hello- I have a variables that contains a string like this usr/pass@SCHEMA I want to extract the usr/pass part and ignore the SCHEMA part, I tried to use this ${dbconn%%@} and apparently it will not work because @ is a special character. I tried \@ and still no go. Any idea how to solve... (1 Reply)
Discussion started by: Nomaad
1 Replies

4. Shell Programming and Scripting

Substituting Characters using SED

Can SED be used to substitute a character (y) with a character (Y) in a specified field? File has 12000 : delimeted rows as; HHC 1 BDE:Lastname, Firstname MI:firstname.mi.lastname@mil:SGT HHC 2 BDE:Lastname, Firstname MI:Firstname.MI.Lastname@mil:SGT I wish to replace the capital letters... (6 Replies)
Discussion started by: altamaha
6 Replies

5. Shell Programming and Scripting

Special characters in a bash variable in sed

Hello, I am trying the following: echo __CHANGEME__ >> testfile VAR1="&&&" sed -i "s|__CHANGEME__|${VAR1}|" testfile cat testfile This results in testfile containing __CHANGEME____CHANGEME____CHANGEME__ Whereas I want it to result in &&& I understand that if VAR1="\&\&\&" then... (3 Replies)
Discussion started by: linuxnewbeee
3 Replies

6. Shell Programming and Scripting

Trouble cutting characters into a string.

I just have a couple of quick questions. I am having trouble with this cut. I am basically trying to cut the string so that i can insert the users guess at the appropriate point in the string. $letters is the character count of the $word. What it seems to do is cut the character into the... (0 Replies)
Discussion started by: Makaer
0 Replies

7. Programming

C++ Special Characters in a String?

Hello. How can i put all of the special characters on my keyboard into a string in c++ ? I tried this but it doesn't work. string characters("~`!@#$%^&*()_-+=|\}]{ How can i accomplish this? Thanks in advance. (1 Reply)
Discussion started by: cbreiny
1 Replies

8. Shell Programming and Scripting

Sed failing for variable with special characters

This has been covered many times earlier but couldnt figure the issue myself. Can you please advise whats wrong on the below code I have a variable with special character ($) and am using that variable to replace another variable in file but however sed is failing to parse it correctly ... (7 Replies)
Discussion started by: sasiharitha
7 Replies

9. Shell Programming and Scripting

Substituting a shell variable in sed

Hi guys, I'm trying to figure out how to use a shell variable inside my sed command. I just want to remove a certain part of a path. I've tried three different combinations and none of them work. Here are the three combinations: echo $file | sed 's/'$test'//' echo $file | sed "s/$test//"... (7 Replies)
Discussion started by: chu816
7 Replies

10. Shell Programming and Scripting

getting error while substituting variable using sed..

I am using script for substitute one variable with another variable like below... below code works fine... sed 's/'$sub_fun'/'$To_sub'/g' But when i run the same code from the script getting below errors.. sed: -e expression #1, char 7: unterminated `s' command please help....... (2 Replies)
Discussion started by: pamu
2 Replies
RDF::Query::Algebra::SubSelect(3pm)			User Contributed Perl Documentation		       RDF::Query::Algebra::SubSelect(3pm)

NAME
RDF::Query::Algebra::SubSelect - Algebra class for Subselects VERSION
This document describes RDF::Query::Algebra::SubSelect version 2.908. METHODS
Beyond the methods documented below, this class inherits methods from the RDF::Query::Algebra class. "new ( $query )" Returns a new SubSelect structure. "construct_args" Returns a list of arguments that, passed to this class' constructor, will produce a clone of this algebra pattern. "query" Returns the sub-select query. "sse" Returns the SSE string for this algebra expression. "as_sparql" Returns the SPARQL string for this algebra expression. "as_hash" Returns the query as a nested set of plain data structures (no objects). "type" Returns the type of this algebra expression. "referenced_variables" Returns a list of the variable names used in this algebra expression. "potentially_bound" Returns a list of the variable names used in this algebra expression that will bind values during execution. "definite_variables" Returns a list of the variable names that will be bound after evaluating this algebra expression. AUTHOR
Gregory Todd Williams <gwilliams@cpan.org> perl v5.14.2 2012-01-31 RDF::Query::Algebra::SubSelect(3pm)
All times are GMT -4. The time now is 04:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy