User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 329,813 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,830 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Views: 109 | Replies: 2
Reply
Join Date: Mar 2008
Posts: 11
Reputation: sjgriffiths is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
sjgriffiths sjgriffiths is offline Offline
Newbie Poster

Uniq on certain fields

  #1  
3 Days Ago
I have the following file

1928282,Stephen LTD,31280938,L34
3128398,Stephen LTD,84327489,L34

I want to uniq on fields 2 & 4, the fields are comma seperated

I cant figure out how to do this....any ideas? im pretty sure uniq does not support this
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2007
Posts: 47
Reputation: radoulov is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
radoulov's Avatar
radoulov radoulov is offline Offline
Light Poster

Re: Uniq on certain fields

  #2  
3 Days Ago
Use nawk or /usr/xpg4/bin/awk on Solaris.

awk -F, '!x[$2,$4]++'  input
Reply With Quote  
Join Date: Oct 2007
Posts: 188
Reputation: eggi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 15
eggi eggi is offline Offline
Junior Poster

Re: Uniq on certain fields

  #3  
3 Days Ago
You can also use the -u flag to sort, which can pick out fields:

sort -t, -u -k2,2 -k4,4

Best wishes,

Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Find Great Help With UNIX Commands Here, As Well! MySysAd.com
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Marketplace (Sponsored Links)
Thread Tools Display Modes

Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 5:58 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC