Re: cut for whole lines

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: steve crandell
Date:  
To: Main PLUG discussion list
Subject: Re: cut for whole lines
Consider appending --tuples-only if you're generating this list with psql.

To your question specifically, this should do it:
cat my_tables.txt | grep -v "\-\-\-" | grep -v ^$ | tail -n +2 | head
-n -1

Though that uses magical hard coded characters which will get you in
trouble later when one little thing about the output you're parsing
changes.

Frankly I'd use the perl DBI.

-s

Craig White wrote:
> I am trying to script reading the table info from postgres into a file.
>
> I need to get rid of the first 2 and last 2 lines and it should be easy
> but obviously cut is for grabbing bits of lines where I need to remove
> the whole line.
>
> # cat my_tables.txt
>        tablename
> -----------------------
>  engine_schema_info
>  plugin_schema_info
> ...snipped here...
>  services
> (43 rows)

>
> I need to lose the top 2 lines:
>       tablename
> ---------------

>
> and the bottom two lines
> (43 rows)
> and a blank line (though this would probably be OK)
>
> how do I accomplish via bash or coreutils (like cut)?
>
> Thanks
>
> Craig
>
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>


--
Steve Crandell
Linux System Operations

    480.282.6047 direct
    480.239.9286 mobile
    480.505.5801 fax
    
    www.icrossing.com


    ATLANTA | CHICAGO | DALLAS | NEW YORK | SAN FRANCISCO | SCOTTSDALE
    Winner of OMMA Magazine's 2005 Agency of the Year: Best Search




---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss