I would like to have a script which is able to perform the below.
Print the whole row if column1 which is "0001" for the below example is the first occurrence. Subsequent "0001" occurrence will not be printed out and so on.
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"
$ 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
It's your shell which is breaking the awk script. Put it in a file or switch to a shell which doesn't barf on the ! character.
I'm sure you will be able to peruse the "perlrun" manual page to figure out what the -a -n -e switches do. Basically -n says loop over the input like awk and -a says tokenize the input like awk, and -e is like in sed to pass a script directly on the command line.