unique command - variation on the theme
I have a large file and want to keep certain lines based on the first word in each. The words are blank-delimited character strings.
The first words are not necessarily unique. I want to keep the uniques, and that's easy enough. Where duplicates are encountered I want to keep only one of each, and the kept line must be the *last* of the duplicates. Sample input file: ALBERT 54 BENJAMIN 37 BILL 24 BILL 25 BILL 77 CARL 40 CARL 44 CHESTER 59 DAVID 23 DAVID 23 DAVID 28 DAVID 61 EDGAR 33 EDWARD 54 EDWARD 59 EDWIN 30 Desired output file: ALBERT 54 BENJAMIN 37 BILL 77 CARL 44 CHESTER 59 DAVID 61 EDGAR 33 EDWARD 59 EDWIN 30 I'm a newbie and still learning the basics, so please: - no awk - no bash - no Perl Let's stick to commands such as uniq, sort, sed, grep, cut, paste, etc. |
Quote:
tac < {InFile} | sort -k1,1 -t' ' -u |
Quote:
|
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
|
All times are GMT -5. The time now is 06:36 PM. |