Guest User

Untitled

a guest
May 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. air
  2. smell
  3. hand
  4. dude
  5. road
  6. cat
  7.  
  8. air,4,21,01,13,3,2
  9. smell,21,4,2,5,6
  10. dude,1,31,42,1
  11. road,1,4,2,1,4
  12. cat,1,5,6,3,1
  13. hand,1,4,2,1,6
  14. mouse,1,3,5,6,2
  15.  
  16. air,4,21,01,13,3,2
  17. smell,21,4,2,5,6
  18. hand,1,4,2,1,6
  19. dude,1,31,42,1
  20. road,1,4,2,1,4
  21. cat,1,5,6,3,1
  22.  
  23. awk -F, 'FNR==NR {a[$1]; next}; $1 in a' file1 file2
  24.  
  25. gawk -F, '
  26. FNR==NR {a[NR]=$1; next};
  27. {b[$1]=$0}
  28. END{for (i in a) if (a[i] in b) print b[a[i]]}
  29. ' file1 file2
  30.  
  31. awk -F, 'FNR==NR {a[$1]=$0; next}; $1 in a {print a[$1]}' file2 file1
  32.  
  33. join -t, -1 2 -2 1 <(nl -s, -ba -nrz file1 | sort -t, -k2)
  34. <(sort -t, -k1 file2) | sort -t, -k2 | cut -d, -f1,3-
  35.  
  36. air,000001,4,21,01,13,3,2
  37. cat,000006,1,5,6,3,1
  38. dude,000004,1,31,42,1
  39. hand,000003,1,4,2,1,6
  40. road,000005,1,4,2,1,4
  41. smell,000002,21,4,2,5,6
  42.  
  43. air,4,21,01,13,3,2
  44. smell,21,4,2,5,6
  45. hand,1,4,2,1,6
  46. dude,1,31,42,1
  47. road,1,4,2,1,4
  48. cat,1,5,6,3,1
  49.  
  50. grep -f file1 file2
Add Comment
Please, Sign In to add comment