Reputation:
I've been looking around here on how to delete duplicates in a file with preserving the order of the file. However, I couldn't find a command that deletes in place and not have to create a new file.
example
sample.txt
one two three one four one five
after deleting duplicates
sample.txt
one two three four five
Upvotes: 0
Views: 49
Reputation: 7791
GNU awk
has the inplace
option.
gawk -i inplace '!seen[$0]++' file.txt
Upvotes: 1