Uncompress and pipe the output to script

43,033

I found the solution:

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

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

Share:
43,033

Related videos on Youtube

crysis405
Author by

crysis405

Updated on September 18, 2022

Comments

  • crysis405
    crysis405 almost 2 years

    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.

    • web.learner
      web.learner over 10 years
      And your question is?
    • crysis405
      crysis405 over 10 years
      that command I wrote doesn't work, I want something that will
    • crysis405
      crysis405 over 10 years
      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?
  • mpen
    mpen over 4 years
    To other readers, -c is for "to stdout"