Register
It is currently Fri Apr 18, 2014 7:09 am

Getting string from line and pasting it to another


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Mar 30, 2012 6:48 am   

Joined: Fri Mar 30, 2012 6:43 am
Posts: 1
From line:
Code:
< div style="left:0px; top:0px; width:100%; height:63px; border-style: solid; border-width: 1px; background-color:#FCF0C4; border-color:#E87511; border-style: solid; border-width: 1px; position:absolute;" >

I want to get (values may be different)
Code:
#FCF0C4

and then paste it to other line
Code:
< div  style="left:2px; top:32px; width:744px; height:27px; display:block; border-style: solid; border-width: 1px; position:absolute; overflow:hidden; background-color:#ffffff;" >
instead of
Code:
#ffffff


Thanks in advance!


Top
 Profile  
 PostPosted: Fri Jul 06, 2012 4:29 am   

Joined: Fri Jul 06, 2012 3:08 am
Posts: 4
Is this the sort of thing you mean?

Code:
#!/bin/bash

s1='< div style="left:0px; top:0px; width:100%; height:63px; border-style: solid; border-width: 1px; background-color:#FCF0C4; border-color:#E87511; border-style: solid; border-width: 1px; position:absolute;" >'

s2='< div  style="left:2px; top:32px; width:744px; height:27px; display:block; border-style: solid; border-width: 1px; position:absolute; overflow:hidden; background-color:#ffffff;" >'

printf "s2 ==> %s\n" "$s2"

bg_col=${s1##*background-color:}
bg_col=${bg_col%%;*}

printf "s2 ==> %s\n" "${s2//background-color:???????/background-color:$bg_col}"


Code:
Output:
++++++

$ ./replace_text
s2 ==> < div  style="left:2px; top:32px; width:744px; height:27px; display:block; border-style: solid; border-width: 1px; position:absolute; overflow:hidden; background-color:#ffffff;" >
s2 ==> < div  style="left:2px; top:32px; width:744px; height:27px; display:block; border-style: solid; border-width: 1px; position:absolute; overflow:hidden; background-color:#FCF0C4;" >



Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP