News for hackers. Stuff that matters.
Re:“But didn't you write an embedded OS?” by flerchin on Sunday May 13, 2018 @10:06AM (#17058951)
sed foo -e 's/ /\n/g' | sort | uniq
Re:“But didn't you write an embedded OS?” by innagadadavida on Sunday May 13, 2018 @01:28PM (#17059961)
If you want to preserve order, this is how you uniq with awk: awk '!x[$0]++'
Re:“But didn't you write an embedded OS?” by amelius on Sunday May 13, 2018 @10:14AM (#17058977)
Yeah, but what if the strings I wanted to sort contain newlines?
Re:“But didn't you write an embedded OS?” by jws on Sunday May 13, 2018 @10:25AM (#17059036)
You (sir|madam), are a feature creep. If it weren’t for people like you and their “real requirements” software would be easy.

By the time you say “unicode” and “collation” the programmer is going to be in serious trouble.

Fortunately the programmer can lawyer the problem. The original requirements don’t specify what the strings are sorted by. I choose “position in original source” file and complete the task with a NOP.

Re:“But didn't you write an embedded OS?” by diegoperini on Sunday May 13, 2018 @11:21AM (#17059352)
echo "Input file already sorted."
Re:“But didn't you write an embedded OS?” by flerchin on Sunday May 13, 2018 @10:21AM (#17059022)
You haven't specified a delimiter.
Re:“But didn't you write an embedded OS?” by stepvhen on Sunday May 13, 2018 @10:59AM (#17059226)
protip:

tr ' ' '\n' < foo | sort | uniq