Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-21-2016, 06:40 PM   #1
Registered: Dec 2011
Location: Chandler, AZ
Posts: 280

Rep: Reputation: Disabled
Using AWK to avoid printing duplicate column values

Goal is to not print column value if it's the same as previous column value.
I have an input file, for example:
A 1
A 2
B 1
B 2
B 3
C 1

I need output like:
A 1
B 1
C 1

Last edited by usao; 06-21-2016 at 06:41 PM.
Old 06-21-2016, 07:09 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 5,449

Rep: Reputation: 420Reputation: 420Reputation: 420Reputation: 420Reputation: 420
Print line if a variable value is not equal to first field value else print second field, set variable to first field value, simple!

Last edited by keefaz; 06-21-2016 at 07:14 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Problem printing column on remote host via script using awk keif Programming 2 10-25-2013 11:00 AM
[SOLVED] How to sum only specific column values in a row using awk? jv61 Linux - Newbie 3 01-17-2013 12:41 PM
Rename duplicate values in a column jv61 Linux - Newbie 4 07-12-2012 09:12 AM
MS Access SELECT Statement to Exclude Duplicate Values in a Specified Column devUnix Programming 4 12-14-2011 11:45 AM
awk column printing schneidz Programming 7 09-29-2005 07:14 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:07 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration