LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   grep error while parsing a page (https://www.linuxquestions.org/questions/linux-general-1/grep-error-while-parsing-a-page-4175489662/)

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

Code:

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

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

Code:

'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:
Code:

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.