sorting including @ in textstring

Issues related to applications and software problems
Post Reply
ostene
Posts: 48
Joined: 2015/01/25 16:10:17

sorting including @ in textstring

Post by ostene » 2021/08/13 09:23:51

Hello,

I do "sort -du Mailfile.txt > Outfifle.txt". The textfile is including @. Command "sort" should sort the textfile
and remove duplicate text. In "okteta" command the ascii-value (40) of @ is grayed out. The textfile is
done with "kwrite" and every line is ended with newline. Problem: Duplicate lines are not removed and
some lines are not sorted. I think I have missed some option in the command.
ostene

sml
Posts: 305
Joined: 2020/01/17 09:01:44

Re: sorting including @ in textstring

Post by sml » 2021/08/13 11:45:33

sort is locale-dependent

Code: Select all

$ echo $'@c\nb\na'|LC_ALL=en_US sort
a
b
@c

Code: Select all

$ echo $'@c\nb\na'|LC_ALL=C sort
@c
a
b

Whoever
Posts: 1357
Joined: 2013/09/06 03:12:10

Re: sorting including @ in textstring

Post by Whoever » 2021/08/18 04:15:20

ostene wrote:
2021/08/13 09:23:51
Hello,

I do "sort -du Mailfile.txt > Outfifle.txt". The textfile is including @. Command "sort" should sort the textfile
and remove duplicate text.
It's entirely possible that I am wrong about this, but I don't think sort removes duplicates. Use "sort | uniq" for that.

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: sorting including @ in textstring

Post by jlehtone » 2021/08/18 07:20:10

@Whoever:
man sort wrote:-u, --unique
with -c, check for strict ordering; without -c, output only the first of an equal run

Post Reply