Objectmix
Tags Register Mark Forums Read

i remember... : awk

This is a discussion on i remember... within the awk forums in Programming Languages category; hello a few years ago i was playing with one liners and i remember awk particulary for being extremely flexible. Well now i go the chance of my life to impress my boss with something i did not do but i am sure awk can do. I have a database that looks like this, the fourth row is tthe company name and i got to serach all record that have a fourth line that matches a compnay name something like this Joe Riggs Diesel Loss last night My Company Something else here Looser Diego Sanchez Nightmare Win Last night My ...


Object Mix > Programming Languages > awk > i remember...

Reply

 

LinkBack Thread Tools
  #1  
Old 12-13-2006, 11:06 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default i remember...

hello a few years ago i was playing with one liners and i remember awk
particulary for being extremely flexible. Well now i go the chance of
my life to impress my boss with something i did not do but i am sure
awk can do. I have a database that looks like this, the fourth row is
tthe company name and i got to serach all record that have a fourth
line that matches a compnay name something like this


Joe Riggs
Diesel
Loss last night
My Company
Something else here
Looser

Diego Sanchez
Nightmare
Win Last night
My Company
Something else here
Wiiner


I need to cat a files with all this records in to something to get all
the records that have the word my company. I could spend time trying to
write this script but i know you guys are genuis
thanks.

Reply With Quote
  #2  
Old 12-14-2006, 12:15 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: i remember...

jcharth@hotmail.com wrote:
> hello a few years ago i was playing with one liners and i remember awk
> particulary for being extremely flexible. Well now i go the chance of
> my life to impress my boss with something i did not do but i am sure
> awk can do. I have a database that looks like this, the fourth row is
> tthe company name and i got to serach all record that have a fourth
> line that matches a compnay name something like this
>
>
> Joe Riggs
> Diesel
> Loss last night
> My Company
> Something else here
> Looser
>
> Diego Sanchez
> Nightmare
> Win Last night
> My Company
> Something else here
> Wiiner
>
>
> I need to cat a files with all this records in to something to get all
> the records that have the word my company. I could spend time trying to
> write this script but i know you guys are genuis
> thanks.
>


Try something along...

awk 'BEGIN{RS="";FS="\n"} $4=="My Company"'

or...

awk 'BEGIN{RS="";FS="\n"} $4=="My Company"{print $0 FS}'

or...

awk 'BEGIN{RS="";FS="\n";ORS="\n\n"} $4=="My Company"'


Janis
Reply With Quote
  #3  
Old 12-14-2006, 10:20 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: i remember...

Thu, 14 Dec 2006 06:14:43 +0100, Janis Papanagnou did cat*:

> jcharth@hotmail.com wrote:
>> hello a few years ago i was playing with one liners and i remember awk
>> particulary for being extremely flexible. Well now i go the chance of
>> my life to impress my boss with something i did not do but i am sure
>> awk can do. I have a database that looks like this, the fourth row is
>> tthe company name and i got to serach all record that have a fourth
>> line that matches a compnay name something like this
>>
>>
>> Joe Riggs
>> Diesel
>> Loss last night
>> My Company
>> Something else here
>> Looser
>>
>> Diego Sanchez
>> Nightmare
>> Win Last night
>> My Company
>> Something else here
>> Wiiner
>>
>>
>> I need to cat a files with all this records in to something to get all
>> the records that have the word my company. I could spend time trying to
>> write this script but i know you guys are genuis
>> thanks.
>>

>
> Try something along...
>
> awk 'BEGIN{RS="";FS="\n"} $4=="My Company"'
>
> or...
>
> awk 'BEGIN{RS="";FS="\n"} $4=="My Company"{print $0 FS}'
>
> or...
>
> awk 'BEGIN{RS="";FS="\n";ORS="\n\n"} $4=="My Company"'



Another variant :

# gawk '$4~/^My Company$/' RS= FS="\n" ORS="\n\n"

( also works with --compat or --posix )

Reply With Quote
Reply

Thread Tools


Similar Threads

Thread Thread Starter Forum Replies Last Post
shouldn't the DIV remember this? usenet DOTNET 4 10-13-2007 04:56 PM
Trying to remember .... usenet Scheme 2 05-02-2007 04:58 AM
Anyone remember an ado.net cheatsheet on the web? usenet ADO DAO RDO RDS 0 03-19-2007 01:02 PM
Something to remember usenet ADO DAO RDO RDS 0 03-08-2006 11:57 AM
OWA Does not Remember PAssword usenet Microsoft Exchange 0 08-27-2004 10:50 AM


All times are GMT -5. The time now is 08:40 AM.