Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Faster and more efficient way to read a file vertically

by Laurent_R (Canon)
on Nov 03, 2017 at 18:27 UTC ( #1202718=note: print w/replies, xml ) Need Help??


in reply to Faster and more efficient way to read a file vertically

This is a perl one-liner doing just what you want:
$ echo 'ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA > ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA > ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA > ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA > ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA > ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA > ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA > ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA > ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA > ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA > ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA > ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA > ACATCACCTCCCACAACGAGGACTACACCATCGTGGAACA' | perl -nE 'say substr($_, + 10, 1);' C C C C C C C C C C C C C
Check, though, that 10 is the right second parameter for substr, you may have to change it depending on which character you want exactly.

Replies are listed 'Best First'.
Re^2: Faster and more efficient way to read a file vertically
by dbuckhal (Hermit) on Nov 03, 2017 at 22:50 UTC
    another one-liner:

    $ perl -F'' -anE 'say $F[9]'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1202718]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2022-05-28 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (99 votes). Check out past polls.

    Notices?