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
Removing leading and trailing spaces only in PERL kumar04 Shell Programming and Scripting 2 04-04-2009 04:17 PM
Leading spaces of variable removed grumm3t Shell Programming and Scripting 2 08-29-2008 03:22 PM
Removing leading zeros from a variable toshidas2000 Shell Programming and Scripting 6 02-27-2008 01:13 PM
Removing leading and trailing spaces of data between the tags in xml. jhmr7 UNIX for Dummies Questions & Answers 2 05-18-2005 11:27 AM
Strip leading and trailing spaces only in a shell variable with embedded spaces jerardfjay Shell Programming and Scripting 6 03-07-2005 02:24 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 09-28-2009
khedu khedu is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 1
Question Removing leading spaces from the variable value.

Hi All,

I am trying to replace the value of a xml tag with a new one. But, the existing value in the xml contain leading spaces and I tried to remove that with different sed commands but all in vain.

For replacing the value I wrote the command in BOLD letters below:

bash-3.00$ polnum=`grep "<PolNumber>" adi99.xml | sed 's:<PolNumber>::;s:</PolNumber>::' | sed 's/^ *\(.*\) *$/\1/'`
bash-3.00$ echo "PolNumber is:"$polnum
PolNumber is: 109301793
newpol=101101
bash-3.00$ echo "cat adi99.xml | sed -e 's/${polnum}/${newpol}/'"

cat adi99.xml | sed -e 's/"THERE ARE SPACES WHICH ARE GETTING REMOVED HERE ONCE I SAVE IT HERE" 109301793/101101/'


cat adi99.xml
<Holding id="Holding_1">
<Policy id="Policy_1">
<PolNumber>109301793</PolNumber>
</Policy>
</Holding>



Can you please suggest a way to remove these spaces.

Last edited by khedu; 09-28-2009 at 03:44 PM..
 

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 08:57 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