You're viewing a comment by Dave Cross and its responses.

April 27, 2011, 16:49

The range operator is cleverer than you think. You can print lines 17 to 30 in a file like this:

perl -ne 'print if 17 .. 30'

You can (obviously) also use that for printing the first 10 lines of a file:

perl -ne '1 .. 10'

Comment Responses

April 27, 2011, 16:51

Dave, wow, I didn't know that. Thanks for the comment, it was very valuable!

April 28, 2011, 05:16

That second example is wrong.

perl -ne 'print if 1 .. 10'

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the first letter of your name: (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.