News for hackers. Stuff that matters.
Re:The Unix Game by cbsmith on Friday May 28, 2021 @05:22PM (#27320679)
Maybe it's just me, but I was already turned off by the use of "cut" in the first question in a way that assumes all the names in the file have exactly one space and exactly two names.
Re:The Unix Game by samatman on Saturday May 29, 2021 @12:40AM (#27323071)
It's a game.

I'd be more bummed if a game gave me five lines of sample data which fit the constraint of "exactly one space and exactly two names", and then the rest of the data violated that constraint.

Or if some of the last names didn't start with a capital letter, like d'Azzo, for that matter.

Re:The Unix Game by 613style on Friday May 28, 2021 @11:39PM (#27322852)
I think there's two parts to this: first, if you know your input meets certain constraints, then there's no benefit to over-complicating the solution. Second, this is a teaching tool. It makes sense to start simply and save the harder version for later.
Re:The Unix Game by cbsmith on Saturday May 29, 2021 @02:05AM (#27323372)
Is it really so awful to do "grep -o '\b\w+%'"? It still won't handle extra space padding at the end of the line, but it's still a lot less ugly than assuming the word after the first space is a last name.
Re:The Unix Game by RasmusLarsen on Saturday May 29, 2021 @03:07AM (#27323567)
In the context of trying to teach people basics, yes, I would argue that is quite awful.
Re:The Unix Game by cbsmith on Saturday May 29, 2021 @05:46AM (#27324138)
Weird, not sure why it did % instead of $ there.
Re:The Unix Game by tasogare on Saturday May 29, 2021 @09:03AM (#27324974)
Same thought here. Processing text with cut and pipes is cute and works when data are regular except in real life there is often lines here and there breaking assumptions. Using a programming language offer way more possibilities to deal with pathological cases.
Re:The Unix Game by cbsmith on Saturday May 29, 2021 @07:36PM (#27329217)
You don't even need a full programming language... just something that does pattern matching that lets you grab "last word from a line".