Saltar al contenido ForoHackers

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

Herramientas de desarrolloCódigo abiertoScripts de shellPruebas
#6463 · · Citar · Denunciar

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 · · Citar · Denunciar

@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 · · Citar · Denunciar

@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 · · Citar · Denunciar

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

#6512 · · Citar · Denunciar

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.

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder