B
B
bychok3002016-10-28 14:05:00
linux
bychok300, 2016-10-28 14:05:00

How to remove duplicate lines in a file?

There is a txt file with the history of terminal commands,

673  sudo mysql-workbanch
  674  sudo mysql-workbench
  675  poweroff
  676  sudo mysql -u root -p
  677  sudo mysql-workbench
  678  poweroff
вывод sort -u

How can I remove duplicate entries? sort -u is not suitable, there are two values ​​\u200b\u200bthe number and the command itself, sorting is not needed, it is necessary that duplicate lines be deleted and deleted along with the number

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Goryachev, 2016-10-28
@bychok300

If a "manual" solution is suitable, then you can convert the test one to csv.
1. Replacing two spaces with ;
2. Change the resolution of the .csv file
3. Compare 2 columns in Libre Office Calc and remove repetitions
In principle, quickly done) And sorting and numbers are saved.

A
Andrey Myvrenik, 2016-10-28
@gim0

If sorting is not important, then as an option:
sort history.txt | uniq -u

M
Max, 2016-10-28
@MaxDukov

recipe

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question