i m try to grep
two lines of html
pattern from a file and print using cat
. The lines are:
<link type="text/css" rel="stylesheet" href="https://test.mydomain.com/store.css">
and
<script type="text/javascript" language="javascript" src="https://test.mydomain.com/store/gwt.nocache.js">
if i use them seperatly using grep
command. like
if grep -F -i -n '<link type="text/css" rel="stylesheet" href="https://test.mydomain.com/store.css">' tmp.html > out.txt; then cat out.txt # IT WORKS.
but i am in need to grep
both the pattern. i tried with egrep
. as
egrep '(pattern1|pattern2)'
as
if egrep -e -i -c '(\<link type\=\"text\/css\" rel\=\"stylesheet\" href\=\"https\:\//test\.mydomain\.com\/gwtstore\/store\.css\"\>|\<link type\=\"text\/css\" rel\=\"stylesheet\" href\=\"https\:\//test\.mydomain\.com\/store\/gwt\.nocache\.js\"\>)' tmp.html > out.txt; then cat out.txt
but the above syntax not working out.. please Assist. all i m try to search two set of html code in a file, if they exit replace with another pattern using sed
command.