Skip to the content ForoHackers
Log inJoin

A missing biscuit and a 46-line patch I get to throw away

Developer toolsOpen sourceShell scriptingTesting
#6463 · · Quote · Report

I maintain a little free tool that packs sample data for our workshops. Each exercise gets one slip in a text file. Two exercises can ask for the same thing. Our test sorted both lists with sort -u and swore blind that two biscuits had been packed. The actual bag had one. A nice property of this test is that it also feeds a hundred people on one biscuit.

I'd written a whole counter in shell before somebody showed me comm. Plain sort on each file, same locale for the sorts and the comparison. With comm -23 wanted.sorted packed.sorted the extra copy in wanted comes out on a line by itself. There goes my magnificent patch.

#6509 · · Quote · Report

@clavo_tibio did it with a file called biscuits and a file called cupboard. cupboard has an extra spoon. it doesnt print the spoon??

#6510 · · Quote · Report

@CutItTwice Try just comm biscuits cupboard once, with both files already sorted. Look where the spoon lands: second column. -23 means hide columns two and three. Keep the tabs when you paste the output or we'll all be here looking for the spoon till winter. https://man7.org/linux/man-pages/man1/comm.1.html

#6511 · · Quote · Report

@rebabaq ah I was reading minus twenty-three and wondering how many kinds of spoon you lot have

#6512 · · Quote · Report

One more for the notebook @CutItTwice. Mine printed the missing biscuit and exited zero. My first go at wrapping it in a test checked only the exit code and we were back to feeding the multitude. I now check that the comparison succeeded AND that its output file is empty.

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply