If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > solumn specific search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-26-04, 00:59
rraajjiibb rraajjiibb is offline
Registered User
 
Join Date: May 2004
Posts: 5
Exclamation solumn specific search

I have a file with each line containing 53 fields separated by semicolons.
I need to extract the matching lines based on matching values from a particular column AND /OR some logical combination of pattern matches from a couple of columns.

In short I want to run SQL like queries on this file .... but from UNIX .

The data looks like as attached

3;10115950;611261;106440;3;8d2d9522;2230982599;123 2600248;0;65;2;1;43;65;2;1;43;
1641;65;7;0;23811450;2;2;2;2;2;1;0;3;3;994;518;7;0 ;2;2;1;1;0;140;0;0;0;4;3;0;0;0
;0;0;0;2;25;27;

3;10115951;612309;1100;1;8d31de39;2230983737;12326 02026;0;33;2;1;34;33;2;1;34;0;
0;0;0;982014290;2;2;2;0;2;1;0;3;3;995;823;7;0;2;0; 1;2;0;56;0;0;0;0;0;0;0;0;0;0;0
;1;25;

3;10115952;612347;0;59;0;2233498694;0;2233498694;0 ;0;0;0;0;0;0;0;1885;230;7;0;0;
0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;8;0;0;0;0;0;0;0;0; 0;0;0;0;4802828128;0;

3;10115953;611938;40797;3;44f2a266;2234358432;1075 033834;0;12;2;2;2;12;2;2;2;617
;69;7;1;02234204762;2;2;1;1;1;1;0;3;3;993;894;7;0; 2;2;1;1;0;84;0;0;0;3;3;0;0;0;0
;0;0;2;25;27;

......

Pl help
Reply With Quote
  #2 (permalink)  
Old 05-26-04, 03:33
iaguigon iaguigon is offline
Registered User
 
Join Date: May 2004
Location: Barcelona, Spain
Posts: 54
Quote:
Originally Posted by rraajjiibb
I have a file with each line containing 53 fields separated by semicolons.
I need to extract the matching lines based on matching values from a particular column AND /OR some logical combination of pattern matches from a couple of columns.

In short I want to run SQL like queries on this file .... but from UNIX .

The data looks like as attached

3;10115950;611261;106440;3;8d2d9522;2230982599;123 2600248;0;65;2;1;43;65;2;1;43;
1641;65;7;0;23811450;2;2;2;2;2;1;0;3;3;994;518;7;0 ;2;2;1;1;0;140;0;0;0;4;3;0;0;0
;0;0;0;2;25;27;

3;10115951;612309;1100;1;8d31de39;2230983737;12326 02026;0;33;2;1;34;33;2;1;34;0;
0;0;0;982014290;2;2;2;0;2;1;0;3;3;995;823;7;0;2;0; 1;2;0;56;0;0;0;0;0;0;0;0;0;0;0
;1;25;

3;10115952;612347;0;59;0;2233498694;0;2233498694;0 ;0;0;0;0;0;0;0;1885;230;7;0;0;
0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;8;0;0;0;0;0;0;0;0; 0;0;0;0;4802828128;0;

3;10115953;611938;40797;3;44f2a266;2234358432;1075 033834;0;12;2;2;2;12;2;2;2;617
;69;7;1;02234204762;2;2;1;1;1;1;0;3;3;993;894;7;0; 2;2;1;1;0;84;0;0;0;3;3;0;0;0;0
;0;0;2;25;27;

......

Pl help
Try awk.
You can do something like awk -F ";" '{ if ($5==3 || $5==1) print $0}'. It should print all lines with the fifth column being 3 or 1.
You can also define external variables and functions. See the man page for details.

Hope this helps

Iņaki
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On