Visit Our UNIX and Linux User Community


sed - replace string question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed - replace string question
# 1  
Old 01-04-2008
sed - replace string question

Hi Everybody

Uning sed I need to replace:
Code:
"count(user) = 0" -o "uid = ftp" -n -o "gid = ftp"

by
Code:
"read only = no"

Thanks in advance.

Last edited by danmero; 01-04-2008 at 02:54 PM.. Reason: Simplify the problem
# 2  
Old 01-04-2008
I don't understand your question fully. Are you saying you want to

REPLACE this entire phrase:
Code:
"count(user) = 0" -o "uid = ftp" -n -o "gid = ftp" -n -b \

WITH this phrase:
Code:
"read only = no"

# 3  
Old 01-04-2008
Thats corect cassj. See the edited post.

Thanks
# 4  
Old 01-04-2008
Try:

Code:
sed 's/"count(user) = 0" -o "uid = ftp" -n -o "gid = ftp" -n -b \\/"read only = no"/'

Just escape the backslash.

Regards
# 5  
Old 01-04-2008
Bug sed - replace string SOLVED

Quote:
Originally Posted by Franklin52
Try:

Code:
sed 's/"count(user) = 0" -o "uid = ftp" -n -o "gid = ftp" -n -b \\/"read only = no"/'

Just escape the backslash.
Golden rules, think a bit before asking Smilie
Code:
 sed 's/\("count(user) = 0" -o "uid = ftp" -n -o "gid = ftp" -n -b\)/"read only = no"/'

Thank Franklin for your help , I understand now where was the original problem(mistake Smilie )

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using sed to replace string

Hello guys, I'm working in a cellular company and i'm trying to do a script to run some commands automaticlly. I'm using Solaris version :SunOS pk-ercuas4 5.10 in my work. I've a file that creates by script named test1.mos that that look like: confb+ gsg+ lt all $date = `date... (1 Reply)
Discussion started by: oferg
1 Replies

2. Shell Programming and Scripting

Replace string in XML file with awk/sed with string from another

Sorry for the long/weird title but I'm stuck on a problem I have. I have this XML file: </member> <member> <name>TransactionID</name> <value><string>123456789123456</string></value> </member> <member> <name>Number</name> ... (9 Replies)
Discussion started by: cozzin
9 Replies

3. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

4. Shell Programming and Scripting

replace (sed?) a string in file with multiple lines (string) from variable

Can someone tell me how I can do this? e.g: a=$(echo -e wert trewt ertert ertert ertert erttert erterte rterter tertertert ert) How do i replace the STRING with $a? I try this: sed -i 's/STRING/'"$a"'/g' filename.ext but this don' t work (2 Replies)
Discussion started by: jforce
2 Replies

5. Programming

Question how to replace last character string

Hi, Could someone help me how to replace last character string. For example $>export T1=abcde $>export T2=xyz my question is how to get result abcdxyz? Many Thanks (2 Replies)
Discussion started by: nicklau81
2 Replies

6. Shell Programming and Scripting

How to use sed to replace the a string in the same file using sed?

How do i replace a string using sed into the same file without creating a intermediate file? (7 Replies)
Discussion started by: gomes1333
7 Replies

7. Shell Programming and Scripting

Using sed to replace a string in file with a string in a variable that contains spaces

Hi, i call my shell like: my_shell "my project name" my script: #!/bin/bash -vx projectname=$1 sed s/'PROJECT_NAME ='/'PROJECT_NAME = '$projectname/ <test_config_doxy >temp cp temp test_config_doxy the following error occurres: sed s/'PROJECT_NAME ... (2 Replies)
Discussion started by: vivelafete
2 Replies

8. UNIX for Dummies Questions & Answers

sed/grep string replace question

Hi all, I know this question has probably been answered before, but I am struggling with this problem, even after googling a million pages. In a file named rdmt.conf I need a single character replaced, the number in the line below CUR_OC4J_ID=1 It will always appear after... (3 Replies)
Discussion started by: Mike AAA
3 Replies

9. Shell Programming and Scripting

sed: replace string with another string (with spaces)

Hi I have an XML file with strings XABCD, XEFGHX and XIJKLX. I would like to replace XABCDX with "This is the first string", XEFGHX with "This is the second string" and XIJKLX with "This is the third string". What is the best way to implement this? Should I have a file with the data that is... (4 Replies)
Discussion started by: zmfcat1
4 Replies

10. Shell Programming and Scripting

SED Replace String Help

I have to replace date in Control file every day i run the script control file looks like this $cat pharma.ctl LOAD DATA INFILE '/usr/bin/sqlscripts/SQL.PharmID.20071206.txt' INTO TABLE uname.TEMP_TABLE FIELDS TERMINATED BY '|' TRAILING NULLCOLS (col_names) i tried $sed -e... (2 Replies)
Discussion started by: prash184u
2 Replies

Featured Tech Videos