Visit Our UNIX and Linux User Community

Sed , Replace a "variable text" inside of a statement

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sed , Replace a "variable text" inside of a statement
# 1  
Old 03-04-2008
Sed , Replace a "variable text" inside of a statement

Please Help... I am trying to manipulte the following line

Before :

the password is the "variable", i need to delete / omit the password in the file, (it occurs several thousand times)
so the tag line looks like


how can this be accomplished using sed commands.

I have been trying to resolve this for about 2 days, i am a novice to sed and now i am reaching out to the experts.
# 2  
Old 03-04-2008
This should work for you.
echo "<user:Account_Password>002786</user:Account_Password>" | sed -e "s/\(<user:Account_Password>\).*\(<\/user:Account_Password>\)/\1\2/"

# 3  
Old 03-04-2008
That rocks and its works. Is it possible to get an interpretation of the code so i am not just cut and pasting and not understanding it.

Thanks for your time in advance.

# 4  
Old 03-04-2008
sed -e "s/\(<block>\).*\(<\/block>\)/\1new\2/"

# 5  
Old 03-04-2008
Thanks a bunch

Previous Thread | Next Thread
Test Your Knowledge in Computers #437
Difficulty: Medium
Vue.js is a free, proprietary JavaScript framework.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using sed command to replace "|" with ^ for all *.dat files in a folder not working

I am trying to use the below sed command to replace all "|" to ^, in a folder had 50 dat files. when i tried with 1 file it worked but when i tried with wild card, is not working. sed -i 's/"|"/\^/g' *.dat Is this the proper way to use sed command thank you very much for help. (3 Replies)
Discussion started by: cplusplus1
3 Replies

2. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

3. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Awk to Search and Replace inside the pipe "|"

Hi, Anyone can help me on how to replace the qoutes inside the pipe | in my Text File like belows; "AAAA"|"Test "1-A""|"Test AAAA"|"This is A" "BBBB"|"Test "1-B""|"Test BBBB"|"This is B" "CCCC"|"My Test C"|"Test "CCCC""|"This is C" The output I need like belows; "AAAA"|"Test 1-A"|"Test... (12 Replies)
Discussion started by: fspalero
12 Replies

6. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

7. Shell Programming and Scripting

sed: a "replace unless match" question

Context: I am using sed in a cronjob to change the dates in a separate sql script every week. Each week the dates must be updated to reflect the Monday and Friday of the previous week. I have solved the problem but in solving it I discovered a major weakness in my knowledge of sed. Lines to be... (0 Replies)
Discussion started by: Bubnoff
0 Replies

8. Shell Programming and Scripting

Help with replacing tabs inside "" with some text/blank

I am poor with scripting;) I have a file in the following format; 'This is a "test in production" of importance.' I want to get rid of the spaces inside the "" part only to get the output as, 'This is a "testinproduction" of importance.' (1 Reply)
Discussion started by: shmathew
1 Replies

9. Shell Programming and Scripting

replace word with using "sed" not work...

Hi, I have a xml text file with the following data, I would like replace F0</Number> to F</Number> only. i used sed to replace, but it not work!! anyone can help? <Number>11 20 03 22 23 21 91 00 F0</Number> <Number>12 20 03 20 99 21 91 20 F0</Number> <Number>10 21 03 21 78 21 92 27... (28 Replies)
Discussion started by: happyv
28 Replies

10. Shell Programming and Scripting

Failed to replace string with "sed"

Hi folks, I have the following configuration file: tofu:/tmp # cat maestroIp= maestroPort=2020 adminPlayPath=<Streaming Agent IP>:2021/streamingGateway/GetPlayList ###This part should not be changed### adminPlayVODProtocol=http username=iptv... (7 Replies)
Discussion started by: nir_s
7 Replies

Featured Tech Videos