grazinggoat
Programmer
Hello - How can I sort uniq (deletes duplicates) of the second field then writes it back to the file:
users1 PROD = bill,tom,larry,john
users2 PROD = bill,tom,bill,larry,john
users3 PROD = bill,tom,larry,john,bill
so that it produces
users1 PROD = bill,john,larry,tom
users2 PROD = bill,john,larry,tom
users3 PROD = bill,john,larry,tom
This is what I get:
cat test.txt|awk -F'=' '{split($2,a,",")asort(a);
> for(i in a)u[a]
> for(i in u){x=x","i;delete u}
> print $2
> {'
awk: syntax error near line 5
awk: illegal statement near line 5
users1 PROD = bill,tom,larry,john
users2 PROD = bill,tom,bill,larry,john
users3 PROD = bill,tom,larry,john,bill
so that it produces
users1 PROD = bill,john,larry,tom
users2 PROD = bill,john,larry,tom
users3 PROD = bill,john,larry,tom
This is what I get:
cat test.txt|awk -F'=' '{split($2,a,",")asort(a);
> for(i in a)u[a]
> for(i in u){x=x","i;delete u}
> print $2
> {'
awk: syntax error near line 5
awk: illegal statement near line 5