I have an HTML file where I need to replace text inside the paragraph element (<p>
) with the capital letters of the same like <p>hi</p>
to <p>HI</p>
.
x=`cat $1 | grep -o '<p>.*</p>' | tr '[:lower:]' '[:upper:]'`
var2=`echo $x`
headerremove=`grep -o '<p>.*</p>' $1`
var3=`echo $headerremove`
echo $var2
echo $var3
sed 's/$var3/$var2/g' "$1"
Input
<h1>head</h1>
<p>hello</p>
Output
<p>HELLO</p>
This is not working as expected. Also I need to remove all other details like all tags and their child elements other than the paragraph element.
var2=`$x`
? (Hint: nothing good.) (2) You show code with twoecho
statements (not to mention ased
command) with output to the stdout, and yet you show only one line of output. Please make your question complete. (3) Figure out exactly what yoursed
command looks like and take a long, hard look at it; that should give you a clue as to what’s going wrong. – G-Man Says 'Reinstate Monica' Apr 25 '18 at 23:25