1

I have a list of contact information I need to process in .txt format seperated by , . We only want to keep SIC codes that start with 65 which is real estate.

The command should only check for the correct field for data that starts with 65.

Please keep in mind that the number wont always be 6531, it just has to start with 65 (6521 6555 6587 for example would be something we would also want to keep)

2,J,John Foraste Photography,atlanticinn@biri.com,68 Middle Hwy,Barrington,RI,2806, , ,733511,Photographic Engineering,atlanticinn.com
3,X,Xerox Corp,danielle_cook@xeroxscanners.com,10 Orms St # 420,Providence,RI,02904-7815,5594547871,4012763242,504403,Copying & Duplicating Machines & Supls,www.xerox.com
4,S,St Sahag & St Mesrob Armenian,h.ghajanian@osjl.com,70 Jefferson St,Providence,RI,02908-4923,4012722832,4012727712,866107,Churches,www.stsahmes.org
13,C,Century 21 Access America,damonray@mail.com,1025 Tiogue Ave,Coventry,RI,02816-6100,4018282100, ,6531,Real Estate, 
14,B,Baxter's Showroom,rbaxters@aol.com,Null,Warwick,RI,0,4017398222,4017397058,594409,Jewelers,baxtersjewelry.com^^majorfindings.com^^robertbaxter.com^^san
17,R,Re/Max South County,ereadey@yahoo.com,56 Wells Street,Westerly,RI,2891,4015962067, ,6531,Real Estate, 
19,L,Lyn Reale - Block Island Realty,saintwolfe@computer.org,215Chapelstreet,Block Island,RI,2807,4012534311, ,653118,Real Estate,stmichaelsbristolri.org
21,R,Re/Max South County,apage@remax.net,56 Wells Street,Westerly,RI,2891,4015962067, ,6531,Real Estate, 
22,V,Vns Home Health Svc,george@vnshomehealth.org,14 Woodruff Ave # 7,Narragansett,RI,02882-3467,4017882253,4017820500,808201,Home Health Service,

After processing the list should be

13,C,Century 21 Access America,damonray@mail.com,1025 Tiogue Ave,Coventry,RI,02816-6100,4018282100, ,6531,Real Estate, 
17,R,Re/Max South County,ereadey@yahoo.com,56 Wells Street,Westerly,RI,2891,4015962067, ,6531,Real Estate, 
19,L,Lyn Reale - Block Island Realty,saintwolfe@computer.org,215Chapelstreet,Block Island,RI,2807,4012534311, ,653118,Real Estate,stmichaelsbristolri.org
21,R,Re/Max South County,apage@remax.net,56 Wells Street,Westerly,RI,2891,4015962067, ,6531,Real Estate, 
Teddy77
  • 2,983

3 Answers3

2

with awk

awk -F, '{if ( $11 ~ /^65/ ) print $0}' file

explanation: use comma as field separator -F, , check if column 11 starts (^) with 65 if ( $11 ~ /^65/ ), if so print whole line print $0

FelixJN
  • 13,566
1

This should do it:

#!/usr/bin/env perl

use strict;
use warnings;

while ( <> ) {
    print if (split /,/)[10] =~ m/^65/;
}

Can one liner it if you like as:

perl -ne 'print if (split /,/)[10] =~ m/^65/;' yourfile
Sobrique
  • 4,424
0
sed '/,65[0-9]*,Real Estate/! d' file.txt
Costas
  • 14,916