2
I have a file that contains lines that look like the following:
14|geauxtigers|90
14|geauxtigers|null
I want to remove all instances in the file with the null as the last term. Is there a way to do this with Unix commands?
I was going to read in the file with Java and look at adjacent lines and remove the line whose adjacent line has similar first two terms but null as the third term. Is there a way to do this through Unix tools?
Edit: I don't want to blindly remove all of the terms with null as the third term, I might have the following entry: 15|lsu|null I'd like to keep it since it is the only entry. It's just that, if there is another line with a third term that is non-null, I would like to keep the non-null value.
So what does this have to do with Java? – Matt Ball – 2011-10-24T20:03:27.277
That looks like a job for the
sed
andgrep
commands, I'll let the experts answer this question – None – 2011-10-24T20:04:45.850i am curious that, 5 answers, but nobody gave an AWK solution for such a typical "awk question" – None – 2011-10-24T20:25:37.313
This is underspecified. Are "similar" lines always adjacent? Do you want the result in the same order as the input? – ninjalj – 2011-10-24T21:36:43.850