Hi people,
i have a nice problem to solve..
in an text page i must change all the "*.php" occourences to the respective lowercase..
Example:
...
<tr><td>
<form action="outputEstrazione.php" method="get">
<table cellspacing='0,5' bgcolor='#000000 '><tr><td>
<font size='2' color='#ffffff ' face='tahoma'><b>Lettura documento input</b></font></td></tr><tr><td>
<table width='100%' height='100%' bgcolor='#ffffff ' cellpadding='1'><tr><td>
...
must be modified in:
...
<tr><td>
<form action="outputestrazione.php" method="get">
<table cellspacing='0,5' bgcolor='#000000 '><tr><td>
<font size='2' color='#ffffff ' face='tahoma'><b>Lettura documento input</b></font></td></tr><tr><td>
<table width='100%' height='100%' bgcolor='#ffffff ' cellpadding='1'><tr><td>
...
("outputEstrazione.php" >>> "outputestrazione.php")
Can you help me? It seems so simply but it's not for me
tnx!
clx
May 5, 2009, 10:26am
2
you are using any webserver and want to convert it on runtime? or you just have a text file?
In general,
for a text file, you can use
if you must want to use awk..
you can use sed to do that also:
sed '/\.php/{
h
s/<.*\"\(.*\.php\)\".*>$/\1/
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyj/
G
s/\(.*\)\n\(<*[^"]*\"\).*\.php\(\".*>\)/\2\1\3/
}' filename
cheers,
Devaraj Takhellambam
Or you could use perl:
$
$ cat input.txt
<tr><td>
<form action="outputEstrazione.php" method="get">
<table cellspacing='0,5' bgcolor='#000000'><tr><td>
<font size='2' color='#ffffff' face='tahoma'><b>Lettura documento input</b></font></td></tr><tr><td>
<table width='100%' height='100%' bgcolor='#ffffff' cellpadding='1'><tr><td>
$
$
$ perl -ne '{if (/(^.*?")(.*?)(\.php.*$)/) {print $1.lc$2.$3,"\n"} else {print}}' input.txt
<tr><td>
<form action="outputestrazione.php" method="get">
<table cellspacing='0,5' bgcolor='#000000'><tr><td>
<font size='2' color='#ffffff' face='tahoma'><b>Lettura documento input</b></font></td></tr><tr><td>
<table width='100%' height='100%' bgcolor='#ffffff' cellpadding='1'><tr><td>
$
$
HTH,
tyler_durden
________________________________________________________
"If you don't claim your humanity, you will become a statistic."
how about below perl code?
open $fh,"<","yourfile";
while(<$fh>){
s/\b(.*)\.php/lc $1 . '.php'/e;
print;
}
hey great great thanks!!
Great solutions, i've chosen the perl one and it works perfectly:
perl -ne '{if (/(^.*?")(.*?)(\.php.*$)/) {print $1.lc$2.$3,"\n"} else {print}}' input.txt
I've never used perl, but i often see it's very useful and want to learn it, do you have any link to a good tutorial (not too complex, for a beginner)?
Thanks again for all the replies! You are simply the best UNIX forum on the net
p.s. sorry for my bad english ^^