LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-30-2013, 11:28 PM   #1
mia_tech
Member
 
Registered: Dec 2007
Location: FL, USA
Distribution: CentOS 5.3, Ubuntu 9.04
Posts: 245

Rep: Reputation: 16
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.
 
Old 12-30-2013, 11:52 PM   #2
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Stretch
Posts: 612

Rep: Reputation: 125Reputation: 125
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Grep \ Shell Script \ Parsing drd0spt Programming 5 09-28-2012 04:34 AM
Help with Sed/Grep/Awk for file parsing StupidNewbie Programming 10 03-18-2012 01:52 PM
parsing a string from grep output in bash xpromisex Programming 2 11-12-2006 09:12 AM
Grep parsing issue selfsck Linux - General 3 07-11-2004 08:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration