[colug-432] help with awk

Stephen Potter spp at unixsa.net
Wed Oct 7 08:36:09 EDT 2015


Assuming the header has "Gender" for the column title,

egrep 'Gender|,M,' source.csv > males.csv
egrep 'Gender|,F,' source.csv > females.csv

Change the title and the criteria for the gender to match your file 
(like ",M$" if at the end, etc).  To make it case insensitive, use 
"egrep -i".

Going back to earlier conversation about shell tests, this could also 
depend on what you are running it on.  The grep on linux allows

grep -E instead of egrep.  It also has grep -P to allow PCRE.

-spp

On 10/6/2015 8:35 PM, Rick Hornsby wrote:
>
>> On Oct 6, 2015, at 18:57, Keith Larson <klarson at k12group.net 
>> <mailto:klarson at k12group.net>> wrote:
>>
>> I would like the header row in both files if possible.
>
> To copy the header line, start thusly:
> head -1 source.csv > males.csv
> head -1 source.csv > females.csv
>
> and every operation following that writes to the files, use the >> 
> append operator.
>
>
>
> _______________________________________________
> colug-432 mailing list
> colug-432 at colug.net
> http://lists.colug.net/mailman/listinfo/colug-432

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20151007/2d921389/attachment.html 


More information about the colug-432 mailing list