LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-10-2008, 11:37 PM   #1
ExoZagNoid
Member
 
Registered: Jun 2004
Location: Gibbons, Alberta, Canada
Distribution: Fedora Core
Posts: 51

Rep: Reputation: 15
Grep to pull specific hyperlinks out of files


Hey people,

Basically I'm looking for a grep command that pulls some Facebook hyperlinks out of multiple text files and dumps all the links into another text file.

Something like

grep -io * http://www.facebook.com/n/?inbox/rea...p&t=?????????? > LinkFile.txt

(not sure if I should use -x or not seeing as how the numbers are different)

They are exactly the same except the 10 numbers at the end. I want to find all these links regardless of what the numbers are and push them into a file. If anyone is super ambitious it'd be neat to make it so the same link doesn't get repeated AND/OR make each link clickable in an HTM file.

I've used some simple grep in the past, but I think this might use regular expressions (which I have not much experience). I've tried this a couple times with horrible results.

Anyways, if not an answer, I'm sure a clue or example would get me going.
Thx,
Exo
 
Old 09-11-2008, 01:00 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Put single quotes around your expressions when they contain shell metacharacters.
Code:
grep -io * 'http://www.facebook.com/n/?inbox/rea...p&t=??????????' > LinkFile.txt
Use egrep or grep -E to use extended regular expressions. Use the [[:digit:]] character class to match digits. Use the quantifier {10} to indicate that you want 10 of the previous atoms. Use backslash to escape special regular expression characters, such as ?, . (dot) and &.

Code:
grep -Eio * 'http://www\.facebook\.com/n/\?inbox/rea...p\&t=[[:digit:]]{10}' > LinkFile.txt
 
  


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
Shell script to grep log for a specific error sfcg Programming 8 06-28-2008 09:12 AM
grep for specific phrases Harry Seldon Linux - Newbie 5 05-27-2008 07:58 PM
How to use grep to search for a specific variable.. memo007 Linux - Software 4 02-24-2007 05:52 PM
An easy way to push and pull files reitzell Linux - Newbie 2 04-27-2005 09:32 PM

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

All times are GMT -5. The time now is 03:47 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