I want to use php’s strip tags in a bash script. I figured I could just cat the html file I want to use and use that input and pipe it into php and then pipe that into something else (sed). Is that possible? I’m not sure exactly how to pipe the output of file.html into the strip_tag function…maybe put it all in a variable? I want the following to keep just the anchor tags…in the following I put in dummy text for strip_tags string because I didn’t know how to pipe file.html in:
cat file.html | php strip_tags("<p><a href='#'>hi</a></p>",'<a>') > removed_tags.html
You can read from STDIN in PHP using the stream URI
php://stdin. As for executing it, you’ll also need to quote the PHP code and use the-roption, as well asechoing the result. So here’s the fixed script: