[NTLUG:Discuss] sed awk question

David Stanaway david at stanaway.net
Tue Aug 13 02:34:46 CDT 2002


The moral of the story is to use something more portable like awk or
perl,

Here is my simple awk version:

$ awk -F, '{a[$1]=$0} END{for(k in a) print a[k]}' < test.txt 
afg,sdf,sdaf
cc,dws,44
asd,333,rewse
aa,f00f,tt

Awk is realy quite a neat text processing tool for most things you that
come up.

On Mon, 2002-08-12 at 15:35, Chris Cox wrote:
> David Stanaway wrote:
> 
> >On Mon, 2002-08-12 at 14:56, Chris Cox wrote:
> >  
> >
> >>-W1.... where did that come from?  Just curious.
> >>    
> >>
> >
> >       -W, --check-fields=N
> >              compare no more than N fields in lines
> >
> > Manual page uniq(1) line 43
> >
> >dstanawa at ciderbox:~$ uniq --version
> >uniq (GNU textutils) 2.0
> >Written by Richard Stallman and David MacKenzie.
> >
> >Copyright (C) 1999 Free Software Foundation, Inc.
> >This is free software; see the source for copying conditions.  There is
> >NO
> >warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> >PURPOSE.
> > 
> >  
> >
> ccox at palette:/realhome/ccox> uniq --version
> uniq (GNU textutils) 2.0.10
> Written by Richard Stallman and David MacKenzie.
> 
> Copyright (C) 2000 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> ccox at palette:/realhome/ccox> uniq -W1
> uniq: invalid option -- W
> Try `uniq --help' for more information.
> 
> ccox at palette:/realhome/ccox> uniq --check-fields=1
> uniq: unrecognized option `--check-fields=1'
> Try `uniq --help' for more information.
> 
> Hmmm... a mystery...it's not in my man page either.
> 
> 
> 
> 
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
-- 
David Stanaway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: This is a digitally signed message part
Url : http://ntlug.org/pipermail/discuss/attachments/20020813/2b5dc9e2/attachment.bin


More information about the Discuss mailing list