sed global substitution for ' character


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed global substitution for ' character
# 1  
Old 12-21-2008
sed global substitution for ' character

Hi all,

I have a text file containing sql commands. I want to use sed to replace the " character with the ' character. But when i run the command below it just replaces it with a space? Do i have the escape the ' character if i want to use it?

cat sql.txt

update customer set custid = 'test" where number = 50041;
update customer set custid = 'test2" where number = 50042;
update customer set custid = 'test3" where number = 10393;

$ cat sql.txt | sed 's/"/'/g

update customer set custid = 'test where number = 50041;
update customer set custid = 'test2 where number = 50042;
update customer set custid = 'test3 where number = 10393;
# 2  
Old 12-21-2008
Try this:

Code:
sed "s/\"/'/" sql.txt > newfile.txt

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed searches a character string for a specified delimiter character, and returns a leading or traili

Hi, Anyone can help using SED searches a character string for a specified delimiter character, and returns a leading or trailing space/blank. Text file : "1"|"ExternalClassDEA519CF5"|"Art1" "2"|"ExternalClass563EA516C"|"Art3" "3"|"ExternalClass305ED16B8"|"Art9" ... ... ... (2 Replies)
Discussion started by: fspalero
2 Replies

2. UNIX for Beginners Questions & Answers

(g)awk conditional substitution issues when attempting to delete character

A portion of my input is as follows: 1087 IKON01,49 A WA- -1 . -1 . 0 W WA- -1 . -1 . 0 . -1 . -1 -1 -1 -1 -1 -1 W 1088 IKON01,49 A J.@QU80MW. 2... (2 Replies)
Discussion started by: jvoot
2 Replies

3. Shell Programming and Scripting

ksh - Get last character from string - Bad Substitution error

I want to get the last character from my machine name using the following code, the default shell is bash, the script runs in ksh. I get 'bad' substitution error on running the script, but works fine if run using dot and space. Why? $ echo $0 bash $ cat -n myenv.sh 1 ... (8 Replies)
Discussion started by: ysrini
8 Replies

4. Shell Programming and Scripting

KSH: substitution character, AWK or SED?

Hi Gurus, I am working with a korn shell script. I should replace in a very great file the character ";" with a space. Example: 2750;~ 2734;~ 2778;~ 2751;~ 2751;~ 2752;~ what the fastest method is? Sed? Awk? Speed is dead main point, Seen the dimensions of the files Thanks (6 Replies)
Discussion started by: GERMANICO
6 Replies

5. Shell Programming and Scripting

In Sed how can I replace starting from the 7th character to the 15th character.

Hi All, Was wondering how I can do the following.... I have a String as follows "ACCTRL000005022RRWDKKEEDKDD...." This string can be in a file called tail.out or in a Variable called $VAR2 Now I have another variable called $VAR1="000004785" (9 bytes long), I need the content of... (5 Replies)
Discussion started by: mohullah
5 Replies

6. Shell Programming and Scripting

Sed character substitution

Hi I have to replace in around 60 files a word an replcae it by another Suppose all the files have a word intelligent i want to replace it by idiot I am planning to use sed for executing this job sed 's/\intelligent/idiot/g' I plan to have a file (test.txt) which contains... (1 Reply)
Discussion started by: ultimatix
1 Replies

7. UNIX for Dummies Questions & Answers

global search and replacement of a non-ascii character

Hi, I need to do a global search and replacement of a non-ascii character. Let me first give the background of my problem. Very frequently, I need to copy set of references from different sources. Typically, a reference would like this: Banumathy et al., 2002 G. Banumathy, V. Singh and U.... (1 Reply)
Discussion started by: effjay
1 Replies

8. Shell Programming and Scripting

Global replace with sed

Hi, I need to change some strings from A to B in a number of files within a directory. Please can someone advise how do I do that? Many thanks (5 Replies)
Discussion started by: canary
5 Replies

9. UNIX for Advanced & Expert Users

global substitution in VI

Hi All, I'm trying to add a carriage return to the end of my lines in a text file using substitution, but I havent found a way as yet. Can anyone help? something along the lines of: :%s/<^A/^M/g obviously, this doesnt work. Many thanks. (11 Replies)
Discussion started by: OLweiser
11 Replies

10. Shell Programming and Scripting

character substitution

Hi , I have a problem , I need to devlope a script where in the user inputs file name , line number , and character position , and a substitution variable , the character at that character position should be substituted by the substitution value for ex say i have a file abc.txt which... (3 Replies)
Discussion started by: viv1
3 Replies
Login or Register to Ask a Question