On Sun, 13 Jun 2021 at 06:51, Patrick Dupre <pdupre@gmx.com> wrote:
Hello,

I wish to remove lines which appear twice in a file, actually
only when they appear more than one time.
How can I do so?

Do you need to keep the lines in the same order?   If not, then
"sort -u" should work.  You may also want to use "uniq".

 % cat nonuniq.txt
dd
aa
bb
cc
bb
aa
 % sort -u nonuniq.txt
aa
bb
cc
dd



--
George N. White III