Try to grep out varnish version does not work

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite
1












I try to read the varnish version from a Linux Command line, but the following does not work:



varnishd -V | grep -P '(?<=varnish-)[0-9.]+' -o


This always returns this



varnishd (varnish-3.0.3 revision 9e6a70f)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2011 Varnish Software AS


instead of just this



3.0.3


Any hints on what I do wrong?



Thanks










share|improve this question

















  • 1




    If you just want the digits in decimal form, you will need something like grep -o '[0-9].[0.9].[0-9]'
    – Raman Sailopal
    Oct 9 '17 at 12:43










  • But this works: "httpd -version | grep -P '(?<=Apache/)[0-9.]+' -o". So why should this not work on the varnish version command?
    – Klaus Hörmann-Engl
    Oct 9 '17 at 12:46







  • 1




    Perhaps varnishd -V writes to stderr not stdout? Try appending 2>&1
    – steeldriver
    Oct 9 '17 at 12:47










  • @steeldriver You were absolutely right. I needed to redirect the stderr to the stdout. Now it works like a charm: 'varnishd -V 2>&1 | grep -P '(?<=varnish-)[0-9.]+' -o' If you make an answer out of it, I will mark it as solved.
    – Klaus Hörmann-Engl
    Oct 9 '17 at 12:53















up vote
0
down vote

favorite
1












I try to read the varnish version from a Linux Command line, but the following does not work:



varnishd -V | grep -P '(?<=varnish-)[0-9.]+' -o


This always returns this



varnishd (varnish-3.0.3 revision 9e6a70f)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2011 Varnish Software AS


instead of just this



3.0.3


Any hints on what I do wrong?



Thanks










share|improve this question

















  • 1




    If you just want the digits in decimal form, you will need something like grep -o '[0-9].[0.9].[0-9]'
    – Raman Sailopal
    Oct 9 '17 at 12:43










  • But this works: "httpd -version | grep -P '(?<=Apache/)[0-9.]+' -o". So why should this not work on the varnish version command?
    – Klaus Hörmann-Engl
    Oct 9 '17 at 12:46







  • 1




    Perhaps varnishd -V writes to stderr not stdout? Try appending 2>&1
    – steeldriver
    Oct 9 '17 at 12:47










  • @steeldriver You were absolutely right. I needed to redirect the stderr to the stdout. Now it works like a charm: 'varnishd -V 2>&1 | grep -P '(?<=varnish-)[0-9.]+' -o' If you make an answer out of it, I will mark it as solved.
    – Klaus Hörmann-Engl
    Oct 9 '17 at 12:53













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





I try to read the varnish version from a Linux Command line, but the following does not work:



varnishd -V | grep -P '(?<=varnish-)[0-9.]+' -o


This always returns this



varnishd (varnish-3.0.3 revision 9e6a70f)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2011 Varnish Software AS


instead of just this



3.0.3


Any hints on what I do wrong?



Thanks










share|improve this question













I try to read the varnish version from a Linux Command line, but the following does not work:



varnishd -V | grep -P '(?<=varnish-)[0-9.]+' -o


This always returns this



varnishd (varnish-3.0.3 revision 9e6a70f)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2011 Varnish Software AS


instead of just this



3.0.3


Any hints on what I do wrong?



Thanks







linux grep varnish






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 9 '17 at 12:33









Klaus Hörmann-Engl

31




31







  • 1




    If you just want the digits in decimal form, you will need something like grep -o '[0-9].[0.9].[0-9]'
    – Raman Sailopal
    Oct 9 '17 at 12:43










  • But this works: "httpd -version | grep -P '(?<=Apache/)[0-9.]+' -o". So why should this not work on the varnish version command?
    – Klaus Hörmann-Engl
    Oct 9 '17 at 12:46







  • 1




    Perhaps varnishd -V writes to stderr not stdout? Try appending 2>&1
    – steeldriver
    Oct 9 '17 at 12:47










  • @steeldriver You were absolutely right. I needed to redirect the stderr to the stdout. Now it works like a charm: 'varnishd -V 2>&1 | grep -P '(?<=varnish-)[0-9.]+' -o' If you make an answer out of it, I will mark it as solved.
    – Klaus Hörmann-Engl
    Oct 9 '17 at 12:53













  • 1




    If you just want the digits in decimal form, you will need something like grep -o '[0-9].[0.9].[0-9]'
    – Raman Sailopal
    Oct 9 '17 at 12:43










  • But this works: "httpd -version | grep -P '(?<=Apache/)[0-9.]+' -o". So why should this not work on the varnish version command?
    – Klaus Hörmann-Engl
    Oct 9 '17 at 12:46







  • 1




    Perhaps varnishd -V writes to stderr not stdout? Try appending 2>&1
    – steeldriver
    Oct 9 '17 at 12:47










  • @steeldriver You were absolutely right. I needed to redirect the stderr to the stdout. Now it works like a charm: 'varnishd -V 2>&1 | grep -P '(?<=varnish-)[0-9.]+' -o' If you make an answer out of it, I will mark it as solved.
    – Klaus Hörmann-Engl
    Oct 9 '17 at 12:53








1




1




If you just want the digits in decimal form, you will need something like grep -o '[0-9].[0.9].[0-9]'
– Raman Sailopal
Oct 9 '17 at 12:43




If you just want the digits in decimal form, you will need something like grep -o '[0-9].[0.9].[0-9]'
– Raman Sailopal
Oct 9 '17 at 12:43












But this works: "httpd -version | grep -P '(?<=Apache/)[0-9.]+' -o". So why should this not work on the varnish version command?
– Klaus Hörmann-Engl
Oct 9 '17 at 12:46





But this works: "httpd -version | grep -P '(?<=Apache/)[0-9.]+' -o". So why should this not work on the varnish version command?
– Klaus Hörmann-Engl
Oct 9 '17 at 12:46





1




1




Perhaps varnishd -V writes to stderr not stdout? Try appending 2>&1
– steeldriver
Oct 9 '17 at 12:47




Perhaps varnishd -V writes to stderr not stdout? Try appending 2>&1
– steeldriver
Oct 9 '17 at 12:47












@steeldriver You were absolutely right. I needed to redirect the stderr to the stdout. Now it works like a charm: 'varnishd -V 2>&1 | grep -P '(?<=varnish-)[0-9.]+' -o' If you make an answer out of it, I will mark it as solved.
– Klaus Hörmann-Engl
Oct 9 '17 at 12:53





@steeldriver You were absolutely right. I needed to redirect the stderr to the stdout. Now it works like a charm: 'varnishd -V 2>&1 | grep -P '(?<=varnish-)[0-9.]+' -o' If you make an answer out of it, I will mark it as solved.
– Klaus Hörmann-Engl
Oct 9 '17 at 12:53











1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










Apparently varnishd -V writes to stderr not stdout. In order to pipe the result into grep, you will need to redirect the stream e.g.



varnishd -V 2>&1 | grep -P '(?<=varnish-)[0-9.]+' -o





share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f397005%2ftry-to-grep-out-varnish-version-does-not-work%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    Apparently varnishd -V writes to stderr not stdout. In order to pipe the result into grep, you will need to redirect the stream e.g.



    varnishd -V 2>&1 | grep -P '(?<=varnish-)[0-9.]+' -o





    share|improve this answer
























      up vote
      0
      down vote



      accepted










      Apparently varnishd -V writes to stderr not stdout. In order to pipe the result into grep, you will need to redirect the stream e.g.



      varnishd -V 2>&1 | grep -P '(?<=varnish-)[0-9.]+' -o





      share|improve this answer






















        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        Apparently varnishd -V writes to stderr not stdout. In order to pipe the result into grep, you will need to redirect the stream e.g.



        varnishd -V 2>&1 | grep -P '(?<=varnish-)[0-9.]+' -o





        share|improve this answer












        Apparently varnishd -V writes to stderr not stdout. In order to pipe the result into grep, you will need to redirect the stream e.g.



        varnishd -V 2>&1 | grep -P '(?<=varnish-)[0-9.]+' -o






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 9 '17 at 13:12









        steeldriver

        32.1k34979




        32.1k34979



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f397005%2ftry-to-grep-out-varnish-version-does-not-work%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?