Guest User

Untitled

a guest
Mar 22nd, 2018
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. id emails
  2. 1 jeff@email.com
  3. 2 larry@email.com
  4. 3 jprice@email.com,jeff@email.com,jeff@stacko.com
  5.  
  6. id emails
  7. 1 jeff@email.com
  8. 2 larry@email.com
  9. 3 jprice@email.com,jeff@stacko.com
  10.  
  11. jeff@email.com
  12. larry@email.com
  13. jprice@email.com,jeff@email.com,jeff@stacko.com
  14.  
  15. awk -F, '{ COMMA="";i=0; while (++i<=NF) {
  16. $1=$i; printf (!seen[$1]++)?COMMA$i:""; COMMA=","}; print ""
  17. }' infile.csv
  18.  
  19. jeff@email.com
  20. larry@email.com
  21. jprice@email.com,jeff@stacko.com
  22.  
  23. awk 'NR==1; NR>1{id=$1"t"; COMMA=$1="";split($0, ar, /,| /);
  24. for(i in ar){if(ar[i]){printf(!seen[ar[i]]++)?id""COMMA""ar[i]:""; COMMA=",";id=""}
  25. } print ""}' infile
  26.  
  27. id emails
  28. 1 jeff@email.com
  29. 2 larry@email.com
  30. 3 jprice@email.com,jeff@stacko.com
Add Comment
Please, Sign In to add comment