Lynx Grep Pattern Match 2 conditions Print from Start to End


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Lynx Grep Pattern Match 2 conditions Print from Start to End
# 1  
Old 11-24-2009
Lynx Grep Pattern Match 2 conditions Print from Start to End

I am working on a scraping project and I am stuck at this tiny grep pattern match.

Sample text :

Code:
FPA List. FPA List. FPA List. FPA List. FPA List. FPA List. FPA List. FPA List. 
ABC Personal Planning

[67]Catherine K. Wat
[68]Cath Wat
[69]Catherine K. Wat
[70]Catherine K. Wat

IFRAME:
[68]http://www.google.com

In the text above, I want to grab the following data :

Code:
[67]Catherine K. Wat
[68]Cath Wat
[69]Catherine K. Wat
[70]Catherine K. Wat

I did somthing like this :
Code:
kkiran@abc:~$ cat FILE | grep -A 5 'Personal Planning'

But the number of contacts varies , so instead of using -A 5, I want to grab everything before IFRAME starting at 'Personal Planning'. I am sure it is a one line command but I cannot find the right flags for it.

Any help is appreciated..

Last edited by kkiran; 11-24-2009 at 12:13 PM.. Reason: Use code tags, please!
# 2  
Old 11-24-2009
Code:
awk '/IFRAME/{exit}_;/Personal Planning/{_++}' infile

# 3  
Old 11-24-2009
Quote:
Originally Posted by radoulov
Code:
awk '/IFRAME/{exit}_;/Personal Planning/{_++}' infile

The Lynx dump doesn't give me any results after I use your code Smilie
# 4  
Old 11-24-2009
Quote:
Originally Posted by kkiran
The Lynx dump doesn't give me any results after I use your code Smilie
Could you post the complete lynx command (including the url if possible)?

---------- Post updated at 05:14 PM ---------- Previous update was at 05:13 PM ----------

If more than one IFRAMEs are present:

Code:
awk '_&&/IFRAME/{exit}_;/Personal Planning/{_++}' infile

# 5  
Old 11-24-2009
Code:
lynx -dump "http://www.google.com" > FILE1

Desired data :
Code:
[12]Language Tools
     
      [13]Advertising Programs - [14]Business Solutions - [15]About Google
    
                             ©2009 - [16]Privacy

p.s : Cannot post the actual URL. It is sensitive info... Thank you..
# 6  
Old 11-24-2009
Given the last example what is the pattern? Do you need something like this?

Code:
lynx -dump --nolist google.com

# 7  
Old 11-24-2009
Quote:
Originally Posted by radoulov
Given the last example what is the pattern? Do you need something like this?

Code:
lynx -dump --nolist google.com

I want to dump this
Code:
lynx -dump google.com

to a FILE. (I don't want to use --nolist cos' i need URLs).

And then I need the following input from this file :

Code:
[12]Language Tools

    [13]Advertising Programs - [14]Business Solutions - [15]About Google

                            ©2009 - [16]Privacy

Thank you for your time...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find matched pattern and print all based on certain conditions

Hi, I am trying to extract data based on certain conditions. My sample input file as below:- lnc-2:1 OnePiece tra_law 500 688 1 . . g_id "R792.8417"# tra_law_id "R792.8417.1"# g_line "2.711647"# KM "8.723820"# lnc-2:1 OnePiece room 500 510 1 . . g_id "R792.8417"# tra_law_id "R792.8417.1"#... (7 Replies)
Discussion started by: bunny_merah19
7 Replies

2. Shell Programming and Scripting

awk to print fields that match using conditions and a default value for non-matching in two files

Trying to use awk to match the contents of each line in file1 with $5 in file2. Both files are tab-delimited and there may be a space or special character in the name being matched in file2, for example in file1 the name is BRCA1 but in file2 the name is BRCA 1 or in file1 name is BCR but in file2... (6 Replies)
Discussion started by: cmccabe
6 Replies

3. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies

4. UNIX for Dummies Questions & Answers

Match Pattern after certain pattern and Print words next to Pattern

Hi experts , im new to Unix,AWK ,and im just not able to get this right. I need to match for some patterns if it matches I need to print the next few words to it.. I have only three such conditions to match… But I need to print only those words that comes after satisfying the first condition..... (2 Replies)
Discussion started by: 100bees
2 Replies

5. Shell Programming and Scripting

Pattern match till the end of the file.

I have a file which is like this ……………………………………….. ………………………………… ………………………………… …………………………………… ……………………………………. ……………………………… <<<from_here>>> ……………………………… ………………………………. I want a script which would fetch the data starting from <<<from_here>>> in the file till the end... (2 Replies)
Discussion started by: halfafringe
2 Replies

6. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

7. Shell Programming and Scripting

Using cat to match pattern start with particular date.

Hi All, version :- SunOS rdrsu1 5.10 Generic_142900-12 sun4u sparc SUNW,SPARC-Enterprise I have a requirenemet, where I have to extrace eroror start with ORA-, which match a perticular date. In below text I only extract out error coming on wed-8 and start with text like "ORA-". hope you... (4 Replies)
Discussion started by: alok.behria
4 Replies

8. Solaris

Using grep to print just the pattern match

Hi all, Is it possible for grep to output just the pattern match and not the whole line when it comes across a match? I know you can adjust the number of trailing or leading lines that are printed, but am yet to find anything that outputs just the pattern match. Cheers, Tim (5 Replies)
Discussion started by: muzzaw
5 Replies

9. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

10. Shell Programming and Scripting

extract a particular start and end pattern from a line

hi In the foll example the whole text in a single line.... i want to extract text from IPTel to RTCPBase.h. want to use this acrooss the whole file Updated: IPTel\platform\core\include\RTCPBase.h \main\MWS2051_Sablime_Int\1... (7 Replies)
Discussion started by: manish205
7 Replies
Login or Register to Ask a Question