1 / 6
Dec 2011

{
if($0 != "42")
    print $0
else
    exit
}

And another alternative solution:

/42/{exit}
{print $0}
  • created

    Dec '11
  • last reply

    Jul '14
  • 5

    replies

  • 1.3k

    views

  • 5

    users

3 months later

Ok, I've found the (maybe) shortest one:

/42/{exit}1
1 year later
6 months later

Initially, i thought
[color=#FF0000]NR<2,/42/[/color]
to be the shortest AWK code but then found that it stops "after" printing 42.
I wonder what the 9-byte accepted code looks like...

EDIT: Turns out the input file is already known and the number preceding 42 is 19. So, here goes...
[color=#FF0000]NR<2,/19/[/color]
or even better with 5-byte code..
[color=#FF0000]NR<38[/color]