-   Linux - General (
-   -   grep error while parsing a page (

mia_tech 12-30-2013 11:28 PM

grep error while parsing a page
I have a script that stores the content (php/html) of a webpage into a variable


page="$(wget -qO- link)"
then I grep the page for especific html tag like: iframe in this case

grep -in iframe page
but I'm getting error.


'rep: unrecognized option '-->
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.

towheedm 12-30-2013 11:52 PM

I don't think grep can search for a pattern in a variable. As far as I'm aware it works only on files.

You can echo the variable and pipe it to grep:

echo $page | grep -in "iframe"
Your search terms must be quoted.

Hope it helps.

All times are GMT -5. The time now is 10:11 AM.