On Win10 C:\>type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe" -ne "say lines()[1,7,3]; " (Line 2 Line 8 Line 4) (Line 11 Nil Nil)
C:\>type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe" -ne "say lines()[1,7,3].join(qq~\n~); " Line 2 Line 8 Line 4 Use of Nil in string context in block at -e line 1 Use of Nil in string context in block at -e line 1 Line 11 and, speaking of that off by one problem ... lines.txt does start with "line 0" C:\> type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe" -ne "my @x = $*IN.lines(); say @x[0,1,7,3]; " (Line 1 Line 2 Line 8 Line 4) 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 "The three great problems of computer science: compiler complexity and 'off-by-one' errors". https://martinfowler.com/bliki/TwoHardThings.html ________________________________ From: Parrot Raiser <1parr...@gmail.com> Sent: Tuesday, August 25, 2020 11:22 AM To: Andy Bach <andy_b...@wiwb.uscourts.gov> Cc: perl6-users <perl6-us...@perl.org>; ToddAndMargo <toddandma...@zoho.com> Subject: Re: print particular lines question 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 >