Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Slicing the output of a command

by marioroy (Prior)
on Jul 10, 2015 at 03:13 UTC ( [id://1134075]=note: print w/replies, xml ) Need Help??


in reply to Re: Slicing the output of a command
in thread Slicing the output of a command

That is beautiful TomDLux. Thus, a demonstration for the OP.

my @foo = `cat very_large_file | head -4`;

Replies are listed 'Best First'.
Re^3: Slicing the output of a command
by BrowserUk (Patriarch) on Jul 10, 2015 at 03:35 UTC

    Why cat the whole file just to discard all but the first four lines:

    my @foo = `head -4 very_large_file`;

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
    I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

      +1 BrowserUk. I'm not sure if the behavior is the same in Windows, but the 'cat command' receives a PIPE signal and exits once count lines have been read by the 'head command'.

        Windows has no signals, so no SIGPIPE there.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-20 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found