[colug-432] help with awk
Jeff Frontz
jeff.frontz at gmail.com
Tue Oct 6 20:25:12 EDT 2015
awk -F, '$5 != "F" { print $0 }' > male.csv < input.csv
awk -F, '$5 != "M" { print $0 }' > female.csv < input.csv
On Tue, Oct 6, 2015 at 7:57 PM, Keith Larson <klarson at k12group.net> wrote:
> I think that awk is the right tool, but I'm open to a better solution if
> there is one.
>
> I have a .csv format file that I want to split into two files based on the
> value found in one of the columns. For discussion purposes, say that the
> file has several different values about a person. FirstName, LastName,
> Phone, DOB and Gender. The file does have a header row. I would like two
> files, one with all entries where gender is M and another file where gender
> is F. I would like the header row in both files if possible. The key is
> that I want the row to be kept completely intact with the delimiters
> remaining in place.
>
> Any suggested solutions? Ideally, I want something that can be done in a
> bash script so that I can run this on a nightly schedule.
>
> Keith Larson
>
> _______________________________________________
> 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/20151006/f2835234/attachment.html
More information about the colug-432
mailing list