[colug-432] help with awk
    Keith Larson 
    klarson at k12group.net
       
    Wed Oct  7 09:21:53 EDT 2015
    
    
  
I like that even better.  Thank you.
 >>> Stephen Potter <spp at unixsa.net> 10/7/2015 8:36 AM >>>
> 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> 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 listcolug-432 at colug.nethttp://lists.colug.net/mailman/listinfo/colug-432  
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20151007/eebbcd8f/attachment.html 
    
    
More information about the colug-432
mailing list