Skip to the content ForoHackers
Log inJoin

awk me acaba de contar doce cajas de diecinueve

Data engineeringDebuggingShell scripting
#18538 · · Quote · Report

mi cuaderno, ya pasado a texto. tres columnas con TAB: color, dueño, cajas. verde sin dueño y 0 cajas; roja, Ana, 12; azul, Luis Mar, 7. awk '{s += $3} END {print s}' me da 12. no sé usar awk pero tengo ojos y la azul es una caja grande con otras seis dentro.

#18627 · · Quote · Report

could you print NF for each line first? default field splitting treats runs of whitespace specially. it doesn't know there's supposed to be an empty middle field or that Luis Mar is one owner.

#18628 · · Quote · Report

sale 2, 3, 4. en la verde, campo 2 es el 0. en la azul, campo 3 es Mar y el 7 se fue al campo 4. hasta ahora pensaba que awk me había robado siete cajas. las tenía el mar, manda huevos.

#18629 · · Quote · Report

Уладальнік можа мець два словы ў імені, а пустое поле не знікае з табліцы. Калі раздзяляльнік табуляцыя, трэба так і сказаць праграме.

#18631 · · Quote · Report

usa el tabulador como separador: en el programa awk BEGIN {FS="\t"}. con tus literales separados por tabs salen tres campos por fila. y el dueño de la azul se vuelve a llamar Luis Mar sin necesidad de pasar otra vez por el registro.

#18632 · · Quote · Report

probado: NF 3,3,3; suma 19. me queda la diferencia entre el verde, que tiene cantidad 0, y otro al que todavía no le conté las cajas. si meto ? ya sé que sumando a lo bruto no va a protestar.

#18645 · · Quote · Report

keep the rows where the count doesn't match your agreed non-negative whole-number format on a separate "needs count" line. test the real zero too. if you just test truth, the only honest empty box gets a second stocktake.

#18648 · · Quote · Report

19 confirmadas, una fila sin contar y la verde sigue contando como contada. Le puse eso arriba en vez de "total". Mi hermano dice que si contamos la grande de fuera son ocho. Se ha quedado fuera de la reunión.

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