Re:“But didn't you write an embedded OS?”
by amelius on Sunday May 13, 2018 @09:51AM
(#17058882)
And what if the strings are separated by spaces instead of newlines?
[ Parent
| on HN ]
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]++'
Yeah, but what if the strings I wanted to sort contain newlines?
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."
You haven't specified a delimiter.