LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 11-20-2007, 08:51 PM   #1
dnoy
Member
 
Registered: Nov 2007
Posts: 69

Rep: Reputation: 15
using grep


So i have a few question:

1. How do I grep between keywords? I want to grep a section between
keyword a and keyword b.

2. how do i extend some columns so they look better when using grep.

I am doing the following:

lynx http://money.cnn.com/data/ipo/upcoming/

and want this info:

Upcoming IPOs | Withdrawn IPOs
Company Shares Range Primary Underwriter Expected
SuccessFactors (SFSF) 0790000 8.00 - 10.00 Morgan Stanley
Iggys House (IGGY) 1400000 6.00 - 6.00 Northland Securities
CreditCards.com (CCRD) 10725000 13.00 - 15.00 Credit Suisse
...


when i use
w3m http://money.cnn.com/data/ipo/upcoming/ | grep -B1 -A40 "Upcoming IPOs"

i get:

SuccessFactors 8.00 Morgan Freddie, Fannie hunt
(SFSF) 10790000 - Stanley 11/20 Report for a few billion
10.00 Retire without
Iggys House 6.00 Northland pinching pennies
(IGGY) 1400000 - Securities 11/20 Report Oil makes fresh run
6.00 at $100, hits record
13.00 Credit high
CreditCards.com 10725000 - Suisse 11/20 Report
(CCRD) 15.00


so my first question is how do i use the keyword to search between Upcoming IPOs and more markets? My solution is to use -B and -A to accomplish this, but i know there is a better way.

the second question is how to i organize all the columns so they are like the first section? I want it to look nice so Fannie hunt (SFSF) is on the same line.


thank you
 
Old 11-20-2007, 09:32 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Hard to say since I can't see markets in your text. If they're on separate lines
awk's the tool for the job.
Code:
$ lynx --dump --width=132 http://money.cnn.com/data/ipo/upcoming/ |awk '/Upcoming IPOs/,/Markets/'
   Upcoming IPOs | [143]Withdrawn IPOs
                     Company                    Shares      Range     Primary Underwriter  Expected
    SuccessFactors (SFSF)                      10790000 8.00 - 10.00  Morgan Stanley       11/20    [144]Report
    Iggys House (IGGY)                         1400000  6.00 - 6.00   Northland Securities 11/20    [145]Report
    CreditCards.com (CCRD)                     10725000 13.00 - 15.00 Credit Suisse        11/20    [146]Report
    Ideation Acquisition Corp. (IDI.U)         10000000 8.00 - 8.00   Lazard               11/20    [147]Report
    Tremisis Energy Acquisition CORP II (TEAX) 9500000  8.00 - 8.00   Merrill Lynch        11/26    [148]Report
    Entropic Communications (ENTR)             10000000 9.00 - 11.00  Credit Suisse        12/6     [149]Report
    Triple-S Management (GTS)                  14000000 16.00 - 18.00 Credit Suisse        12/7     [150]Report
    CampusU (CMPS)                             3500000  5.50 - 6.50   Maxim Group LLC      12/10    [151]Report

   [152]More Markets


Cheers,
Tink

Last edited by Tinkster; 11-20-2007 at 09:35 PM. Reason: added width=132 for formatting reasons
 
Old 11-20-2007, 10:16 PM   #3
dnoy
Member
 
Registered: Nov 2007
Posts: 69

Original Poster
Rep: Reputation: 15
thank you so much, this exactly what i needed!
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to grep multiple filters with grep LinuxLover Linux - Enterprise 1 10-18-2007 07:12 AM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 04:56 AM
grep: grep for two substrings? eur0dad Linux - General 2 08-17-2006 04:03 PM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 11:36 AM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM

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

All times are GMT -5. The time now is 02:19 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
Open Source Consulting | Domain Registration