18

I have a script that takes an input with a -i flag. The input file I have is compressed (.gz). What I want to do (not sure it's possible), because the file is huge, do some thing like this:

gunzip -c myfile.gz | myScript.pl -i STDIN -o myoutfile.txt 

So pipe the output of the decompression to my scripts input flag.

5
  • And your question is?
    – Seth
    Feb 10 '14 at 0:54
  • that command I wrote doesn't work, I want something that will
    – crysis405
    Feb 10 '14 at 0:55
  • well you have a space between my and script. If you used -o first and then -i it would work (remove the STDIN)
    – Seth
    Feb 10 '14 at 0:57
  • sorry about the space, that should not be there. The script is now giving me an error that I haven't provided an input. Does this have to be specifically specified in the perl script, if you want to do piping like this?
    – crysis405
    Feb 10 '14 at 0:59
  • Never done perl, so I can't say.
    – Seth
    Feb 10 '14 at 1:19
26

I found the solution:

gunzip -c myfile.gz | myScript.pl -o myoutfile.txt -i -

it was the - after -i that did the trick.

1
  • 11
    To other readers, -c is for "to stdout"
    – mpen
    Feb 14 '20 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.