with ~150,000 rows. I need to look for instances where the value in col $1 is the same in consecutive rows. When a duplicate row is found, I need to remove the duplicate row, and write it to a second file. I guess you would just create two new files, one with a single copy of each line (whether or not the row occurs one or more than once in the input file), and a second file that gives the rows that were found to be duplicates.
I'm not sure how to go about this, and I can't do it in excel, so some assistance would be appreciated. There could be instances of 3 or more in a row, I'm not sure. I guess it makes sense to just keep the first instance of each multiple.
I was numbering the cols with $0 as the first col, is that not right? Now that I think about it, $0 is the whole line, if I remember right.
Will this work with awk, or do I need nawk?
I probably need in index field, but I probably don't need to preserve the values from the input file. I could just do another line of awk to add a new index.
The sample you posted is "line numbered" is it the output of an awk command of yours ?
If so, show it to us and provide and example of the very initial input file you have, before any formatting.
---------- Post updated at 12:33 AM ---------- Previous update was at 12:30 AM ----------
When you state :
"I need to remove the duplicate row"
Do you means that 2 same consecutive lines should :
a) appear only once ?
or
b) should not appear at all ?
The answer is b, needs to appear only once in the output. The formatting of the input file is pretty far back in the tool chain and I don't see much value in redoing that part. It is just as easy to add a new col. The string in $1 is the index anyway.
And I'm going to keep confusing you, sorry I meant option a. It's been one of those days, since I'm trying to work on three different projects, one in python, one in c++, and one in bash.