![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Search for all the unique file extension | riverside | Shell Programming and Scripting | 1 | 04-09-2008 04:47 PM |
| Need to find only unique values for a given tag across the files | sudheshnaiyer | UNIX for Dummies Questions & Answers | 8 | 09-03-2007 12:53 AM |
| to retrieve unique values | mahalakshmi | Shell Programming and Scripting | 3 | 02-05-2007 09:30 AM |
| sorting file and unique commnad.. | amon | Shell Programming and Scripting | 2 | 02-16-2006 05:19 AM |
| Unique cell vaules in a file | rahulrathod | Shell Programming and Scripting | 3 | 01-17-2006 07:42 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Getting Unique values in a file
Hi,
I have a file like this: Some_String_Here 123 123 123 321 321 321 3432 3221 557 886 321 321 I would like to find only the unique values in the files and get the following output: Some_String_Here 123 321 3432 3221 557 886 I am trying to get this done using awk. Can someone please point me towards the right direction? Edit: Ahaa... I figured out one solution: Code:
{
for(i=1;i<=NF;i++) {
uni[$i]++;
}
for(i in uni) {
print uni[i], i;
}
}
Last edited by Legend986; 10-14-2008 at 01:34 PM.. |
|
||||
|
Quote:
Code:
{
for(i=1;i<=NF;i++) {
uni[$i]++;
}
for(i in uni) {
if ( uni[i] == 1 ) {
print i;
}
}
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|