Unix/Linux Go Back    


Homework & Coursework Questions Students must use and complete the template provided. If you don't, your post may be deleted! Special homework rules apply here.

Attributes value substitution with sed command

Homework & Coursework Questions


Tags
sed, sed - replace text with variable, sed append, shell

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 08-12-2015
Bijayan Sarkar Bijayan Sarkar is offline
Registered User
 
Join Date: Jun 2015
Last Activity: 20 August 2015, 1:36 PM EDT
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Attributes value substitution with sed command

1. The problem statement, all variables and given/known data:
Hi,
I am trying to substitute an attributes value using sed command but it is only possible to substitute the value without space.


2. Relevant commands, code, scripts, algorithms:
input xml
Code:
<BillingAddress11300000 Tag="11300000" SectionID="BLA" CustAddrName="CLAUDIA LUCIA DE ALMEIDA" CustAddrStreet="AV ENGENHEIRO RICHARD" CustAddrState="RJ" CustAddrZip="20561-090" CustAddrStreetNo="64" CustAddrComplement="APTO 303" CustAddrCity="RIO DE JANEIRO" CustAddrCounty="GRAJAU"/>

it will read the attribute and value will store it in variable
required output
Code:
<BillingAddress11300000 Tag="11300000" SectionID="BLA" CustAddrName="Rodrigo DE Silva" CustAddrStreet="AV ENGENHEIRO RICHARD" CustAddrState="RJ" CustAddrZip="20561-090" CustAddrStreetNo="64" CustAddrComplement="APTO 303" CustAddrCity="RIO DE JANEIRO" CustAddrCounty="GRAJAU"/>


3. The attempts at a solution (include all code and scripts):
I used the following script
Code:
#!/bin/bash
echo "Enter the attribute name"
read att
echo "enter new value"
read value

sed "s|$att\=\S*\S|$att=\"$value\"|g" test.xml>>out.xml

It is possible to substitute the attribute's value with this code with no space but it is not possible the f value substitution (The one with the space) with this script
How to implement this scenario?
#
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course)

School Name:Jalpaiguri Govt Engg College
Professor:Swapan kr Sengupta
Course Number:CSE502

Last edited by Don Cragun; 08-12-2015 at 10:51 AM.. Reason: Change ICODE tags to CODE tags.
Sponsored Links
    #2  
Old Unix and Linux 08-12-2015
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 22 September 2017, 3:03 PM EDT
Location: Aachen, Germany
Posts: 11,367
Thanks: 297
Thanked 3,523 Times in 3,242 Posts
I'm afraid this is not the entire form; please complete!
Sponsored Links
    #3  
Old Unix and Linux 08-12-2015
MadeInGermany MadeInGermany is offline Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 22 September 2017, 5:39 PM EDT
Location: Simplicity
Posts: 3,748
Thanks: 306
Thanked 1,257 Times in 1,136 Posts
Is this coursework at all?
    #4  
Old Unix and Linux 08-12-2015
Bijayan Sarkar Bijayan Sarkar is offline
Registered User
 
Join Date: Jun 2015
Last Activity: 20 August 2015, 1:36 PM EDT
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
yes,It will be great if you help regarding this.
Thanks
Sponsored Links
    #5  
Old Unix and Linux 08-12-2015
vbe's Unix or Linux Image
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 22 September 2017, 2:53 PM EDT
Location: Switzerland - GE
Posts: 6,453
Thanks: 283
Thanked 549 Times in 511 Posts
For that you will have to fill completely the form, missing info=School...
Please read:
Notice: You Must Include Complete School Name, Professor and Course Number!
Sponsored Links
    #6  
Old Unix and Linux 08-12-2015
Bijayan Sarkar Bijayan Sarkar is offline
Registered User
 
Join Date: Jun 2015
Last Activity: 20 August 2015, 1:36 PM EDT
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Sir,
I have added the same
Sponsored Links
    #7  
Old Unix and Linux 08-12-2015
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 22 September 2017, 6:04 PM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 5,561
Thanks: 106
Thanked 1,569 Times in 1,161 Posts
Quote:
Originally Posted by Bijayan Sarkar View Post
I have added the same
It seems you didn't - or at least not successfully. Nobody can (that is: is allowed to) help you until this is corrected.

bakunin
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sed insert command and variable expansion/command substitution glev2005 UNIX for Dummies Questions & Answers 8 03-09-2010 02:18 PM
Single command to change the attributes of all luns presented to an AIX host kanna_geekworkz AIX 1 11-02-2009 05:53 PM
sed substitution som.nitk Shell Programming and Scripting 5 03-21-2009 11:39 PM
SED Substitution shubhranshu Shell Programming and Scripting 1 11-11-2008 03:50 AM
Substitution using SED shubhranshu Shell Programming and Scripting 2 11-11-2008 12:13 AM



All times are GMT -4. The time now is 01:37 AM.