Note that there are some explanatory texts on larger screens.

plurals
  1. POshellscript, download tg and pipeline stdout to tar, get http header in stderr?
    primarykey
    data
    text
    <p>The shellscript I am trying to write is to</p> <ol> <li>download a tarball and stdout to <code>tar</code> to uncompress it</li> <li>at the same time parse the http headers found at stderr</li> <li>set the parsed result at #2 to a variable.</li> </ol> <p>For #1:</p> <pre><code>$ wget -Sq -O- "https://api.github.com/repos/est/est/tarball/master" | tar -zmxf - </code></pre> <p>I enabled the <code>-S</code> option, which shows server response to stderr, I want to parse the header a bit for the string commit hash , and set it to a variable called <code>$rev</code></p> <pre><code>$ rev=$(wget -Sq -O /dev/null "https://api.github.com/repos/est/est/tarball/master" 2&gt;&amp;1 | grep "Content-Disposition:" | tail -1 | awk 'match($0, /filename=.+\-([a-zA-Z0-9]+)\./, f){ print f[1] }') $ echo $rev dacd56e </code></pre> <p>So basically, I want a shellscript that could</p> <ol> <li>pipe stdout to a command, also pipe stderr to another command</li> <li>parse the stderr and set the output as a variable</li> <li>do not create temporary files</li> </ol> <p>For #1 <a href="https://stackoverflow.com/a/9217228/41948">https://stackoverflow.com/a/9217228/41948</a></p> <p>For #2 I found <a href="https://stackoverflow.com/questions/374687/">the answer</a> is the <code>read</code> command, but unfortunately the variable can be only found at a subshell.</p> <p>So how do I pass the variable found at <code>read</code> command subshell to the parent shell?</p> <p>Or how do I write a shellscript like this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload