remove lines with duplicate first field

view full story

http://www.unix.com – Trying to cut down the size of some log files. Now that I write this out it looks more dificult than i thought it would be. Need a bash script or command that goes sequentially through all lines of a file, and does this: if field1 (space separated) is the number 2012 print the entire line. Do this DEFINITELY ALWAYS. if field1 is not the number 2012, follow this rule: if field1 of current line is same as field1 of previous line, DONT print the line, otherwise DO print the line. Another way of saying the rule is: only if field1 of current line is DIFFERENT than field1 of the (HowTos)