Sponsored Content
Top Forums Shell Programming and Scripting sed: how to replace regex with a ' (quote) mark Post 302340973 by KenJackson on Tuesday 4th of August 2009 08:44:37 PM
Old 08-04-2009
The problem with what you tried, CraigMoore, is that you have two backslashes, \\. The first one escapes the second one, so you have a net of one backslash acting as a regular character, not escaping what follows it.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

single or double quote in SED

i m trying the following command but its not working: sed 's/find/\'replace\'/g' myFile but the sed enters into new line # sed 's/find/re\'place/g' myFile > I havn't any idea how to put single quote in my replace string. Your early help woud be appreciated. Thanx (2 Replies)
Discussion started by: asami
2 Replies

2. Shell Programming and Scripting

How to get rid of double quote in sed.

Hi, i am using sed command to grep just a valuable data for my report generating. Thanks to the person who assists me on before thread. the problem that i encounter now is when i executed below command The output will give me like below output in between the data, there is a double quote. How... (6 Replies)
Discussion started by: anakiar
6 Replies

3. Shell Programming and Scripting

Regex in grep to match all lines ending with a double quote (") OR a single quote (')

Hi, I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file: Name = "abc" The regex I'm using to match the same is: egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
6 Replies

4. Shell Programming and Scripting

Replace a string in quote to uppercase

Hi, I need to find all strings in single quote and change the case of the string to UPPER. Example: Input: xyz abc ccc 'zxxx7U' dfsdf sdfdd aaa 'oR77' and 'or88' Output: xyz abc ccc 'ZXXX7U' dfsdf sdfdd aaa 'OR77' and 'OR88' Appreciate your help!! Thanks Selva (6 Replies)
Discussion started by: selkum
6 Replies

5. Shell Programming and Scripting

replace a single quote using sed command.

Hi, How do I replace the charachters = '*' to = '^' using Sed commands. As I have several * in the script, thus I have to replace the single quotes too. Please let me know any solution. I have tried the escape character backslash '\' but it doesnt help. sed "s/= \'*\'/=... (2 Replies)
Discussion started by: prachifun
2 Replies

6. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

7. UNIX for Dummies Questions & Answers

find single quote in a string and replace it

Hi, I have variable inside shell script - from_item. from_item = 40.1'1/16 i have to first find out whether FROM_ITEM contains single quote('). If yes, then that need to be replace with two quotes (''). How to do it inside shell script? Please note that inside shell script........ (4 Replies)
Discussion started by: yogichavan
4 Replies

8. Shell Programming and Scripting

Expanding regex in quote

Hi Experts, I'm trying to match and perform the substitution (below) but failed. <File1> Attributes = "SampleAttributes" Attributes1 = "SampleAttributes1" Command: grep Attributes File1 | sed 's|Attributes\s=\s\"\"|Attributes = \"ReplaceAttributes\"|' Any ideas? :( (2 Replies)
Discussion started by: antderu
2 Replies

9. Shell Programming and Scripting

How to replace quote symbol(") and dot(.) with some other values!!

Hi , I have below input file 1.order number is useful. 2.vendor_id is produced. 3.the vandor name is "malawar". I want output file like 1. order number is useful. 2. vendor_id is produced. 3. the vandor name is VmalawarV. in input file line number 1.order number there is no... (4 Replies)
Discussion started by: vinothsekark
4 Replies

10. Shell Programming and Scripting

Replace HTML tags using sed regex

I need all the end tags of </font> to be replaced with new line yet enclosing tag to be retained </font>. Please help me in this regard. Input: <font>abc</font>def<font>ghi</font> Output: <font>abc</font> def <font>ghi</font> (3 Replies)
Discussion started by: Badhrish
3 Replies
ADDSLASHES(3)								 1							     ADDSLASHES(3)

addslashes - Quote string with slashes

SYNOPSIS
string addslashes (string $str) DESCRIPTION
Returns a string with backslashes before characters that need to be escaped. These characters are single quote ( '), double quote ( "), backslash ( ) and NUL (the NULL byte). An example use of addslashes(3) is when you're entering data into string that is evaluated by PHP. For example, O'Reilly is stored in $str, you need to escape $str. (e.g. eval("echo '".addslashes($str)."';"); ) To escape database parameters, DBMS specific escape function (e.g. mysqli_real_escape_string(3) for MySQL or pg_escape_literal(3), pg_escape_string(3) for PostgreSQL) should be used for security reasons. DBMSes have differect escape specification for identifiers (e.g. Table name, field name) than parameters. Some DBMS such as PostgreSQL provides identifier escape function, pg_escape_identifier(3), but not all DBMS provides identifier escape API. If this is the case, refer to your database system manual for proper escaping method. If your DBMS doesn't have an escape function and the DBMS uses to escape special chars, you might be able to use this function only when this escape method is adequate for your database. Please note that use of addslashes(3) for database parameter escaping can be cause of security issues on most databases. The PHP directive magic_quotes_gpc was on by default before PHP 5.4, and it essentially ran addslashes(3) on all GET, POST, and COOKIE data. Do not use addslashes(3) on strings that have already been escaped with magic_quotes_gpc as you'll then do double escaping. The func- tion get_magic_quotes_gpc(3) may come in handy for checking this. PARAMETERS
o $str - The string to be escaped. RETURN VALUES
Returns the escaped string. EXAMPLES
Example #1 An addslashes(3) example <?php $str = "Is your name O'Reilly?"; // Outputs: Is your name O'Reilly? echo addslashes($str); ?> SEE ALSO
stripcslashes(3), stripslashes(3), addcslashes(3), htmlspecialchars(3), quotemeta(3), get_magic_quotes_gpc(3). PHP Documentation Group ADDSLASHES(3)
All times are GMT -4. The time now is 10:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy