sed issues with strange char


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed issues with strange char
# 1  
Old 11-20-2008
Question sed issues with strange char

Hi all,

I try to create a shell script to had the xiti tag at the end of servals web pages just before the <body/> tag.

here is my script :

Code:
#!/bin/bash
##################################################################


rm -R /home/hibern/TEMP/hibern
cp -R /home/hibern/TEMP/hibernorig /home/hibern/TEMP/hibern
value=0

cat << EOF > /tmp/xiti.tmp
<!--\
Xt_param = 's=279747&p=';\
try {Xt_r = top.document.referrer;}\
catch(e) {Xt_r = document.referrer; }\
Xt_h = new Date();\
Xt_i = '<img width="39" height="25" border="0" alt="" ';\
Xt_i += 'src="http://logv33.xiti.com/hit.xiti?'+Xt_param;\
Xt_i += '&hl='+Xt_h.getHours()+'x'+Xt_h.getMinutes()+'x'+Xt_h.getSeconds();\
if(parseFloat(navigator.appVersion)>=4)\
{Xt_s=screen;Xt_i+='&r='+Xt_s.width+'x'+Xt_s.height+'x'+Xt_s.pixelDepth+'x'+Xt_s.colorDepth;}\
document.write(Xt_i+'&ref='+Xt_r.replace(/[<>"]/g, '').replace(/&/g, '$')+'" title="Internet Audience">');\
//-->\
</script>\
<noscript>\
Mesure d'audience ROI statistique webanalytics par <img width="39" height="25" src="http://logv33.xiti.com/hit.xiti?s=279747&p=" alt="WebAnalytics" />\
</noscript></a>\
EOF

for file in `find  /home/hibern/TEMP/hibern -name '*.html' -print`
do

export m_tag=`cat /tmp/xiti.tmp`

sed -e 's/<body>/'$m_tag'/g' "$file" > "$file".tmp && mv -f "$file".tmp "$file"
done

and here is my error :-(

Code:
sed: -e expression #1, char 39: unterminated `s' command

thanks in advance for your help
# 2  
Old 11-20-2008
Try:
Code:
sed -e 's/<body>/'"$m_tag"'/g' "$file" > "$file".tmp && mv -f "$file".tmp "$file"

# 3  
Old 11-21-2008
CPU & Memory

Hi,

Check this

sed -e 's/<body>/${m_tag}/g' "$file" > "$file".tmp && mv -f "$file".tmp "$file"




Thanks,

Thangaraju
# 4  
Old 11-21-2008
Code:
sed -e "s/<body>/${m_tag}/g" "$file" > "$file".tmp && mv -f "$file".tmp "$file"

Drop all the single quotes and use double quotes. Remember, single quotes disable parameter expansion. See the following

Code:
[/tmp]$ a='some text'
[/tmp]$ echo $a
some text
[/tmp]$ echo '$a'
$a
[/tmp]$ echo "$a"
some text

# 5  
Old 11-21-2008
Thanks for your answer, but it's not working :-(

i tried line by line the and i thing this is due to { char. (that' for some thing like a macro)

i have tried with \{ but the problème still their :-(
# 6  
Old 11-23-2008
MySQL Solved

Thanks for your help, my issue is solved, here is the code :

Quote:
#!/bin/bash
##################################################################

rm -R /home/hibern/TEMP/hibern
cp -R /home/hibern/TEMP/hibernorig /home/hibern/TEMP/hibern
cat << EOF > /tmp/xiti.tmp
<!--\
Xt_param='s=279747&p=';\
try {Xt_r = top.document.referrer;}\
catch(e) {Xt_r = document.referrer; }\
Xt_h = new Date();\
Xt_i=\'<img width="39" height="25" border="0" alt=""\';\
Xt_i +=\'src="http:\/\/logv33.xiti.com\/hit.xiti?\'+Xt_param;\
Xt_i += \'\&hl=\'+Xt_h.getHours()+\'x\'+Xt_h.getMinutes()+\'x\'+Xt_h.getSeconds();\
if(parseFloat(navigator.appVersion)>=4)\
{Xt_s=screen;Xt_i+=\'\&r=\'+Xt_s.width+\'x\'+Xt_s.height+\'x\'+Xt_s.pixelDepth+\'x\'+Xt_s.colorDepth ;}\
document.write(Xt_i+\'\&ref=\'+Xt_r.replace(\/[<>"]\/g, \'\').replace(\/&\/g, \'$\')+'" title="Internet Audience">\');\
\/\/-->\
<\/script>\
<noscript>\
Mesure d'audience ROI statistique webanalytics par <img width="39" height="25" src="http:\/\/logv33.xiti.com\/hit.xiti?s=279747&p="\ alt="WebAnalytics" \/>\
<\/noscript><\/a><\/body>
EOF
export m_tag=`cat /tmp/xiti.tmp`
echo "Value for m_tag : "$m_tag
for file in `find /home/hibern/TEMP/hibern -name '*.html' -print`
do
#sed -e 's/<body\/>/'"$m_tag"'/g' "$file" > "$file".tmp && mv -f "$file".tmp "$file"
sed -e 's/<\/body>/\'"$m_tag"'/g' "$file" > "$file".tmp && mv -f "$file".tmp "$file"
done
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

How to remove a special char using sed

consider this is my sample file format. in this i want to remove ^@ with space . please help me in this problm 7305,1310184890,0,0,12,201370,FCASTBHBR0 ,XX ,2,1,2,0,^@,1,1,0,3,1303862400,0,1577923199,1,10,FCASTOR SEED EX-BHABHAR ... (2 Replies)
Discussion started by: ponmuthu-lnx
2 Replies

2. Shell Programming and Scripting

sed returns error "sed: -e expression #1, char 18: unterminated `s' command"

Hello All, I have something like below LDC100/rel/prod/libinactrl.a LAA2000/rel/prod/libinactrl.a I want to remove till first forward slash that is outputshould be as below rel/prod/libinactrl.a rel/prod/libinactrl.a How can I do that ??? (8 Replies)
Discussion started by: anand.shah
8 Replies

3. Shell Programming and Scripting

Strange Sed !!

wload/lscp/home/lscpvbf > v=1/1/1/ wload/lscp/home/lscpvbf > v=`echo $v|sed -e "s/\//\\\//g"`;echo $v 1/1/1/ wload/lscp/home/lscpvbf > v=1/1/1/ wload/lscp/home/lscpvbf > v=`echo $v|sed -e 's/\//\\\//g'`;echo $v sed: Function s/\//\\//g cannot be parsed. wload/lscp/home/lscpvbf > v=1/1/1/... (5 Replies)
Discussion started by: vidyadhar85
5 Replies

4. Shell Programming and Scripting

sed: -e expression #1, char 21: unterminated `s' command

I have read many threads, but I still didn't find the right answer. May be i didn't find the right thread, though are so many threads for the same question. Basically the situation is - find date in a file and replace it with another date. (its not homework, its part of lot of a big processing,... (10 Replies)
Discussion started by: avinthm
10 Replies

5. Shell Programming and Scripting

Removing special char's with sed

Hi, I've a txt file which contains the following kind of listed data 18971 ./aosrp18.r 15340 ./aosrp12.r 22996 ./aosrp08.r 17125 ./aosrp06.r I'm trying to get rid of the ./ in the file and have tried the following with sed but I'm not getting the correct result... I'm not sure what way... (7 Replies)
Discussion started by: Jazmania
7 Replies

6. Shell Programming and Scripting

sed - delete until char x

Hi, I got a Textfile contains hundreds of lines like this: 3 02 8293820 0 22 22 All I need is this: 293820 0 22 22 So i decided to delete until the first '8' comes up. But how I can realize that? (9 Replies)
Discussion started by: mcW
9 Replies

7. Shell Programming and Scripting

strange behaviour from sed???

Hi all, I want to do a very simple thing with sed. I want to print out the line number of a disk I have defined in /etc/exports, so I do: It's all good, but here's the problem. When I define md0 in a variable, I get nothing from sed: Why is that? can anybody please help? Thanks (2 Replies)
Discussion started by: alirezan
2 Replies

8. Shell Programming and Scripting

sed escape char

Hi, For the following complex code , <!-- ... (2 Replies)
Discussion started by: fed.linuxgossip
2 Replies

9. UNIX for Advanced & Expert Users

Strange sed behaviour

$ echo a.bc | sed -e "s/\|/\\|/g" |a|.|b|c| $ Is the behavior of the sed statement expected ? Or is this a bug in sed ? OS details Linux 2.6.9-55.0.0.0.2.ELsmp #1 SMP Wed May 2 14:59:56 PDT 2007 i686 i686 i386 GNU/Linux (8 Replies)
Discussion started by: vino
8 Replies

10. UNIX for Dummies Questions & Answers

strange sed behavior

I have a file called products.kp which contains, for example, 12345678,1^M 87654321,2^M 13579123,3 when I run the command cat products.kp| sed -f kp.sed where kp.sed contains s,^M,, I get the output 12345678,1 87654321,2 13579123,3 (5 Replies)
Discussion started by: Kevin Pryke
5 Replies
Login or Register to Ask a Question