Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. 'sort_field=$47; $47=""; !seen[$0]++ { print $0 " " sort_field }'
  2.  
  3. $ cat file
  4. 1 2 3 4
  5. 5 6 7 8
  6. 1 2 3 x
  7. a b c d
  8. 5 6 7 y
  9.  
  10. awk '
  11. {
  12. line = $0 # remember the original state of this line
  13. NF-- # forget about the last field
  14. }
  15. !seen[$0]++ {print line} # if the "new" line is unique, print the "old" line
  16. ' file
  17.  
  18. 1 2 3 4
  19. 5 6 7 8
  20. a b c d
  21.  
  22. sort -uk1,46 infile.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement