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 ...
![]() |
| | LinkBack | Thread Tools |
|
#1
| |||
| |||
| 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. |
|
#2
| |||
| |||
| 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 |
|
#3
| |||
| |||
| 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 ) |
![]() |
« Previous Thread
|
Next Thread »
| Thread Tools | |
| |
| ||||
| 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.




