The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 03-17-2008
Raynon Raynon is offline
Registered User
  
 

Join Date: Sep 2006
Location: Sg
Posts: 350
Quote:
Originally Posted by radoulov View Post
Like a FAQ
Awk:


Code:
awk '!x[$1]++' file

Use nawk or /usr/xpg4/bin/awk on Solaris.

Perl:


Code:
perl -ane'print unless $x{$F[0]}++' file
Hi radoulov,

The perl code seems to work but not the awk.
Can you help ? I am using solaris by the way.

Also, can you explain your perl code so that i can understand better. What is the function of "-ane"


Code:
$ nawk '!x[$1]++' file
x[$1]++': Event not found
$ awk '!x[$1]++' file
x[$1]++': Event not found
$ /usr/xpg4/bin/awk '!x[$1]++' file
x[$1]++': Event not found


Last edited by Raynon; 03-17-2008 at 09:12 PM..