SED: Replacing $1 with $2 escape problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SED: Replacing $1 with $2 escape problem
# 8  
Old 11-28-2008
Thanks Christoph.

The problem is, the string to be replaced will be given by a user on a webpage which allows the user total freedom.

This is then used as input to sed, which replaces a line in a word document. The user expects any character on the keyboard they enter, to be displayed flawlessly in the word doc, so its not a case of choosing characters which may not be used, as any character can be used.

So if I choose / as the delimitor, and escape that out manually, your saying I should be ok to go?

Its strange how & doesn't cause you troubles and it does for me, I will investigate this further, but I don't think printf's escaping, will escape all sed specials for me.

Last edited by mark007; 11-28-2008 at 07:58 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to escape % with sed?

Hello, I am running ubuntu 16.04 I searched "how to replace dot by % using sed" but no luck. file My.Name.Is.Earl Expected output My%Name%Is%Earl I tried: sed -i "s|.||g" file sed -i "s|.|{%}|g" file sed -i "s|.|\%|g" file I'd appreciate your help Thank you Boris (6 Replies)
Discussion started by: baris35
6 Replies

2. Shell Programming and Scripting

Perl/sed Escape Syntax Problem . . .

Greetings! I've run into this before; and am having a spot of trouble trying to figure out the way that Perl would prefer the following example syntax to be formed:#!/usr/bin/perl use strict; use warnings; use diagnostics; `sed -i 's/Hi Mom!\|Hi Dad!/Bye Everyone!/I' ./test.txt`;Perl... (5 Replies)
Discussion started by: LinQ
5 Replies

3. Shell Programming and Scripting

sed - with escape character

i have string as below str=".<date>" in which i need to replace < with /< , when i tried with sed , got the output. --> echo $str | sed 's/</\\</g' .\<date> when i tried to assign it to a variable , i am not getting the same --> a=`echo $str | sed 's/</\\</g'` ; echo $a... (4 Replies)
Discussion started by: expert
4 Replies

4. Shell Programming and Scripting

Problem with using a sed to add escape character \ before $ and ' symbols

Hi all, I've got a problem with sed. Want to use it to add escape character \ before $ and ' symbols so condition='1'$some will become condition=\'1\'\$some echo "condition='1'$some" | sed 's/\($\)/\\\1/g' is not working properly. Can somebody help me with this please? Regards,... (7 Replies)
Discussion started by: johny_be_good
7 Replies

5. Shell Programming and Scripting

problem in replacing asterisk in sed

Hi all, Sed is the one which always trobules me :( here is my input : *** it industry need to be evolved *** in the world and hope so *** to be dream the output i am expecting is : *** it industry need to be evolved *** in the world and hope so *** to be dream ... (4 Replies)
Discussion started by: panyam
4 Replies

6. Shell Programming and Scripting

problem with sed while replacing a string with another

Hi, I have a line something like this sys,systematic,system I want to replace only the word system with HI I used sed for this as below echo sys,systematic,system | sed 's/system/HI/' but I got output as sys,HIatic,system I wanted output as sys,systematic,HI Please tell me... (9 Replies)
Discussion started by: friendyboy
9 Replies

7. Shell Programming and Scripting

Escape character in sed

Hello experts I am trying to write a shell script which will add ' ' to a unix variable and then pass it to oracle for inserting to a table. I am running the script as root and I have to do a su -c . The problem is the character ' is not recognised inside sed even after adding escape... (1 Reply)
Discussion started by: pvedaa
1 Replies

8. UNIX for Dummies Questions & Answers

sed problem replacing long strings

Hi all, I have a script which uses sed to replace one string with another. The problem is, the string to be matched, and its replacement are coming in as two command line arguments $1 and $2 $1 and $2 can be absolutely anything, but both should be treated purely as strings. My sed command... (1 Reply)
Discussion started by: mark007
1 Replies

9. Shell Programming and Scripting

Escape character - sed

Hi All, How do i write in sed for the 6th and 7th field of etc/passwd file as it involves "/" character? Does mine below is correct? It's incomplete script as i need help with syntax as i always getting may errors :( Example of etc/passwd file: blah:x:1055:600:blah... (6 Replies)
Discussion started by: c00kie88
6 Replies

10. UNIX for Dummies Questions & Answers

possible to escape the \ character in sed?

is it possible to escape the \ character in sed? right now I'm trying to replace all occurances of \ with \\ sed \"s|test|test_replacement|g\" file1 > output; #this works fine sed \"s|\\|\\\|g\" file1 > output; #this generates the following error: sed: -e expression #1, char 17:... (1 Reply)
Discussion started by: gammaman
1 Replies
Login or Register to Ask a Question
LIQUIDSOAP(1)						      General Commands Manual						     LIQUIDSOAP(1)

NAME
liquidsoap - a multimedia streaming language SYNOPSIS
liquidsoap [options] [script|expression] DESCRIPTION
Liquidsoap is a programming language for describing multimedia streaming systems. It is very flexible, making simple things simple but giving a lot of control for advanced uses. Liquidsoap supports audio, video and MIDI streams, and a wide range of input/output operators including Icecast and various soundcard APIs. It can perform a broad range of signal processing, combine streams in various ways, support custom transitions, generate sound procedurally... and all this can be assembled as you wish. Input files can be accessed remotely, or even be synthesized on the fly using external scripts such as speech synthesis. Finally, interaction with a running liquidsoap instance is possible via telnet or socket. Liquidsoap scripts passed on the command line will be evaluated: they shall be used to define the streaming system to be ran. It is possi- ble to pass multiple scripts; they will all be ran successively, and definitions from one script can be used in subsequent ones. A script will be read from standard input if - is given as script filename. Information about scripting liquidsoap is available on our website: http://savonet.sf.net/ If the parameter is not a file it will be treated as an expression which will be executed. It is a convenient way to test simple one-line scripts. When running only one-liners, the default is to log messages directly on stdout rather than to a file. OPTIONS
- Read script from standard input. -- Stop parsing the command-line and pass subsequent items to the script. --debug Print debugging log messages. --dynamic-plugins-dir path Directory where to look for plugins. --errors-as-warnings Issue warnings instead of fatal errors for unused variables and ignored expressions. If you are not sure about it, it is better to not use it. --interactive Start an interactive interpreter. --list-plugins List all plugins (builtin scripting values, supported formats and protocols). --list-plugins-xml List all plugins (builtin scripting values, supported formats and protocols), output as XML. --no-pervasives Do not load pervasive script libraries. --version Display liquidsoap's version. -c, --check Check and evaluate scripts but do not perform any streaming. -cl, --check-lib Like --check but treats all scripts and expressions as libraries, so that unused toplevel variables are not reported. -d, --daemon Run in daemon mode. -f, --force-start For advanced dynamic uses: force liquidsoap to start even when no active source is initially defined. -h plugin Print the description of a plugin, eg. a builtin scripting function. -i Display infered types. -p, --parse-only Parse scripts but do not type-check and run them. -q, --quiet Do not print log messages on standard output. -r filename Process a request. -T, --disable-telnet Disable the telnet server. -U, --disable-unix-socket Disable the unix socket. -t, --enable-telnet Enable the telnet server. -u, --enable-unix-socket Enable the unix socket. -v, --verbose Print log messages on standard output. --conf-descr-key key Describe a configuration key. --conf-descr Show all configuration keys with their documentation. --conf-descr-liqi Show all configuration keys with their documentation in liqi (documentation wiki) format. --conf-dump Dump the configuration state -help, --help Display this list of options SEE ALSO
Our website http://savonet.sf.net/ and the HTML documentation coming with your distribution of liquidsoap. AUTHOR
Savonet team <savonet-users@lists.sourceforge.net> Liquidsoap 1.0.1 June 25, 2012 LIQUIDSOAP(1)