LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-29-2009, 11:01 PM   #1
Natski
LQ Newbie
 
Registered: Oct 2009
Posts: 5

Rep: Reputation: 0
elinks question


Hi everyone,

I am using elinks in a bash script and trying to pull out a particular hyperlink on a webpage. elinks displays hyperlinks in an enumerated manner, and I know which number link I want. For example, let say I want link number 2 on the website www.example.com...

I have tried mylink=`elinks -dump http://example.com | grep http | grep '2.'` to set a variable $mylink as the link I want, but unfortunately that leads to 2, 12, 22, 32, etc all being picked up as well. I only want 2!

So my question is, does elinks have an option (I couldn't see one in the man pages) where one can specify to output only link number 2 in the dump?

Thanks,

Natski
 
Old 10-29-2009, 11:28 PM   #2
evil_empire
Member
 
Registered: Mar 2005
Distribution: Fedora Core 3
Posts: 176

Rep: Reputation: 31
Hi,
try this

mylink='elinks -dump http://example.com | grep http | grep "\<2.\>"'

I don't know if that . was intentional or not. But the key is, if you put the search term inside a pair of angular bracket, grep will search for a exact match.

Last edited by evil_empire; 10-29-2009 at 11:30 PM.
 
Old 10-30-2009, 11:39 AM   #3
Natski
LQ Newbie
 
Registered: Oct 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Hmm... won't that command still grep 12. 22. 32. etc... as well?
 
Old 10-30-2009, 12:04 PM   #4
evil_empire
Member
 
Registered: Mar 2005
Distribution: Fedora Core 3
Posts: 176

Rep: Reputation: 31
why don't u try it? no it wont, it'll grab a exact match so 12, 22, 32 won't be a 2 for grep.
 
Old 10-31-2009, 03:16 PM   #5
Natski
LQ Newbie
 
Registered: Oct 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Using the above, grep found no matches for some reason, despite the fact the grep http output has plenty of 2.'s in it...
 
Old 10-31-2009, 09:41 PM   #6
evil_empire
Member
 
Registered: Mar 2005
Distribution: Fedora Core 3
Posts: 176

Rep: Reputation: 31
Can you try this?
elinks -dump http://example.com | grep http | grep "\<2.\>"

Probably it got screwed up because of the '' & '.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make elinks transparent nephish Linux - Software 4 09-22-2009 09:52 AM
elinks and pdfs ?xunil Linux - Software 2 03-12-2008 08:41 PM
Slackware 10.2 installing ELINKS bobby_hawk Slackware 6 08-05-2006 07:24 PM
Using JavaScript in Elinks corbis_demon Linux - Software 0 03-21-2006 08:48 AM
Elinks: javascript problem ashesh Linux - General 1 07-21-2003 03:06 AM


All times are GMT -5. The time now is 10:04 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration