Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'sort_field=$47; $47=""; !seen[$0]++ { print $0 " " sort_field }'
- $ cat file
- 1 2 3 4
- 5 6 7 8
- 1 2 3 x
- a b c d
- 5 6 7 y
- awk '
- {
- line = $0 # remember the original state of this line
- NF-- # forget about the last field
- }
- !seen[$0]++ {print line} # if the "new" line is unique, print the "old" line
- ' file
- 1 2 3 4
- 5 6 7 8
- a b c d
- sort -uk1,46 infile.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement