That will golf a little (and improve it) to:

$ raku -e '.say for lines()[3,2,5]' lines.txt

but you have to remember that it's zero-based. I used the first sample
file and got
Line 4
Line 3
Line 6

"The three great problems of computer science: compiler complexity and
'off-by-one' errors".


On 8/25/20, Andy Bach <andy_b...@wiwb.uscourts.gov> wrote:
>> Assigning  `my @x=$_.lines` puts everything into $x[0]
>
> Trying this on windows
>
> C:\> raku.exe   -e "my @x = 'lines.txt'.IO.lines; say
> @x[1,7,3].join(qq~\n~); "
> Line 1
> Line 7
> Line 3
>
> or
> C:\> raku.exe -e " say 'lines.txt'.IO.lines[1,7,3].join(qq~\n~); "
> Line 1
> Line 7
> Line 3
>
> a
>
> Andy Bach, BS, MSCMECFA
> Systems Mangler
> Internet: andy_b...@wiwb.uscourts.gov<mailto:andy_b...@wiwb.uscourts.gov>
> Voice: (608) 261-5738, Cell: (608) 658-1890
>
> Every man has the right to an opinion but no man
> has a right to be wrong in his facts. Nor, above all,
> to persist in errors as to facts. Bernard Baruch
>
> ________________________________
> From: ToddAndMargo via perl6-users <perl6-us...@perl.org>
> Sent: Monday, August 24, 2020 9:35 PM
> To: perl6-users <perl6-us...@perl.org>
> Subject: print particular lines question
>
> Hi All,
>
> I seems I should know how to do this, but
> I am drawing a blank.
>
> $ cat Lines.txt | raku -ne 'say $_;'
> Line 1
> Line 2
> Line 3
> Line 4
> Line 5
> Line 6
> Line 7
> Line 8
> Line 9
> Line 10
> Line 11
>
>
> I want to print liens 1, 3, and 7.
>
> Assigning  `my @x=$_.lines` puts everything into $x[0]
>
>
> Many thanks,
> -T
>

Reply via email to