The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how can i replace "(", "\" "+" in a file mail2sant Shell Programming and Scripting 3 04-23-2008 12:10 AM
"unexpected end of file" when Iīm use EOF inside block if ricardo.ludwig Shell Programming and Scripting 4 03-28-2008 03:45 PM
Running Windows "inside" a Linux-like OS? heliotos Linux 6 12-27-2007 12:38 AM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
Convert "text" to "packed-decimal"? HuskyJim UNIX for Dummies Questions & Answers 2 06-08-2001 03:59 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-04-2008
jackn7 jackn7 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 3
Sed , Replace a "variable text" inside of a statement

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

Before :
<user:Account_Password>002786</user:Account_Password>

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

After:
<user:Account_Password></user:Account_Password>

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 (permalink)  
Old 03-04-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,441
This should work for you.

Code:
echo "<user:Account_Password>002786</user:Account_Password>" | sed -e "s/\(<user:Account_Password>\).*\(<\/user:Account_Password>\)/\1\2/"

  #3 (permalink)  
Old 03-04-2008
jackn7 jackn7 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 3
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.

Steve
  #4 (permalink)  
Old 03-04-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,441

Code:
sed -e "s/\(<block>\).*\(<\/block>\)/\1new\2/"

  #5 (permalink)  
Old 03-04-2008
jackn7 jackn7 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 3
Thanks a bunch
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:08 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0