Bash: info with systemctl

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








up vote
5
down vote

favorite












With systemctl status name.service | grep Active I get this info:



Active: active (running) since Mon 2018-05-14 21:44:09 CEST; 5s ago


How can I get the same info but without: "Active: "?







share|improve this question


















  • 3




    What do you want this information for? As noted in the man page, systemctl status is intended to be human-readable: if you're going to start parsing/scripting it, you would likely be better off using systemctl show e.g. systemctl show ssh.service --property=ActiveState,SubState,ExecMainStartTimestamp
    – steeldriver
    May 14 at 20:10










  • ok, I read the properties but your string will get ExecMainStartTimestamp=Mon 2018-05-14 22:11:37 CEST ActiveState=active SubState=running on 3 lines
    – Lilia
    May 14 at 20:19















up vote
5
down vote

favorite












With systemctl status name.service | grep Active I get this info:



Active: active (running) since Mon 2018-05-14 21:44:09 CEST; 5s ago


How can I get the same info but without: "Active: "?







share|improve this question


















  • 3




    What do you want this information for? As noted in the man page, systemctl status is intended to be human-readable: if you're going to start parsing/scripting it, you would likely be better off using systemctl show e.g. systemctl show ssh.service --property=ActiveState,SubState,ExecMainStartTimestamp
    – steeldriver
    May 14 at 20:10










  • ok, I read the properties but your string will get ExecMainStartTimestamp=Mon 2018-05-14 22:11:37 CEST ActiveState=active SubState=running on 3 lines
    – Lilia
    May 14 at 20:19













up vote
5
down vote

favorite









up vote
5
down vote

favorite











With systemctl status name.service | grep Active I get this info:



Active: active (running) since Mon 2018-05-14 21:44:09 CEST; 5s ago


How can I get the same info but without: "Active: "?







share|improve this question














With systemctl status name.service | grep Active I get this info:



Active: active (running) since Mon 2018-05-14 21:44:09 CEST; 5s ago


How can I get the same info but without: "Active: "?









share|improve this question













share|improve this question




share|improve this question








edited May 14 at 20:17









dessert

19.6k55594




19.6k55594










asked May 14 at 19:47









Lilia

312




312







  • 3




    What do you want this information for? As noted in the man page, systemctl status is intended to be human-readable: if you're going to start parsing/scripting it, you would likely be better off using systemctl show e.g. systemctl show ssh.service --property=ActiveState,SubState,ExecMainStartTimestamp
    – steeldriver
    May 14 at 20:10










  • ok, I read the properties but your string will get ExecMainStartTimestamp=Mon 2018-05-14 22:11:37 CEST ActiveState=active SubState=running on 3 lines
    – Lilia
    May 14 at 20:19













  • 3




    What do you want this information for? As noted in the man page, systemctl status is intended to be human-readable: if you're going to start parsing/scripting it, you would likely be better off using systemctl show e.g. systemctl show ssh.service --property=ActiveState,SubState,ExecMainStartTimestamp
    – steeldriver
    May 14 at 20:10










  • ok, I read the properties but your string will get ExecMainStartTimestamp=Mon 2018-05-14 22:11:37 CEST ActiveState=active SubState=running on 3 lines
    – Lilia
    May 14 at 20:19








3




3




What do you want this information for? As noted in the man page, systemctl status is intended to be human-readable: if you're going to start parsing/scripting it, you would likely be better off using systemctl show e.g. systemctl show ssh.service --property=ActiveState,SubState,ExecMainStartTimestamp
– steeldriver
May 14 at 20:10




What do you want this information for? As noted in the man page, systemctl status is intended to be human-readable: if you're going to start parsing/scripting it, you would likely be better off using systemctl show e.g. systemctl show ssh.service --property=ActiveState,SubState,ExecMainStartTimestamp
– steeldriver
May 14 at 20:10












ok, I read the properties but your string will get ExecMainStartTimestamp=Mon 2018-05-14 22:11:37 CEST ActiveState=active SubState=running on 3 lines
– Lilia
May 14 at 20:19





ok, I read the properties but your string will get ExecMainStartTimestamp=Mon 2018-05-14 22:11:37 CEST ActiveState=active SubState=running on 3 lines
– Lilia
May 14 at 20:19











1 Answer
1






active

oldest

votes

















up vote
7
down vote















You can use



grep -oP 'Active: K.*'


to print the line without “Active: ”:



$ systemctl status ssh.service | grep Active 
Active: active (running) since Sat 2018-03-31 14:15:07 CEST; 1 months 13 days ago
$ systemctl status ssh.service | grep -oP 'Active: K.*'
active (running) since Sat 2018-03-31 14:15:07 CEST; 1 months 13 days ago



  • -o tells grep to print only the matched parts of a matching line


  • -P enables Perl-compatible regular expressions (PCRE), that’s needed to use K, which keeps the text matched so far out of the overall regex match.





share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    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: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2faskubuntu.com%2fquestions%2f1036251%2fbash-info-with-systemctl%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
    7
    down vote















    You can use



    grep -oP 'Active: K.*'


    to print the line without “Active: ”:



    $ systemctl status ssh.service | grep Active 
    Active: active (running) since Sat 2018-03-31 14:15:07 CEST; 1 months 13 days ago
    $ systemctl status ssh.service | grep -oP 'Active: K.*'
    active (running) since Sat 2018-03-31 14:15:07 CEST; 1 months 13 days ago



    • -o tells grep to print only the matched parts of a matching line


    • -P enables Perl-compatible regular expressions (PCRE), that’s needed to use K, which keeps the text matched so far out of the overall regex match.





    share|improve this answer


























      up vote
      7
      down vote















      You can use



      grep -oP 'Active: K.*'


      to print the line without “Active: ”:



      $ systemctl status ssh.service | grep Active 
      Active: active (running) since Sat 2018-03-31 14:15:07 CEST; 1 months 13 days ago
      $ systemctl status ssh.service | grep -oP 'Active: K.*'
      active (running) since Sat 2018-03-31 14:15:07 CEST; 1 months 13 days ago



      • -o tells grep to print only the matched parts of a matching line


      • -P enables Perl-compatible regular expressions (PCRE), that’s needed to use K, which keeps the text matched so far out of the overall regex match.





      share|improve this answer
























        up vote
        7
        down vote










        up vote
        7
        down vote











        You can use



        grep -oP 'Active: K.*'


        to print the line without “Active: ”:



        $ systemctl status ssh.service | grep Active 
        Active: active (running) since Sat 2018-03-31 14:15:07 CEST; 1 months 13 days ago
        $ systemctl status ssh.service | grep -oP 'Active: K.*'
        active (running) since Sat 2018-03-31 14:15:07 CEST; 1 months 13 days ago



        • -o tells grep to print only the matched parts of a matching line


        • -P enables Perl-compatible regular expressions (PCRE), that’s needed to use K, which keeps the text matched so far out of the overall regex match.





        share|improve this answer
















        You can use



        grep -oP 'Active: K.*'


        to print the line without “Active: ”:



        $ systemctl status ssh.service | grep Active 
        Active: active (running) since Sat 2018-03-31 14:15:07 CEST; 1 months 13 days ago
        $ systemctl status ssh.service | grep -oP 'Active: K.*'
        active (running) since Sat 2018-03-31 14:15:07 CEST; 1 months 13 days ago



        • -o tells grep to print only the matched parts of a matching line


        • -P enables Perl-compatible regular expressions (PCRE), that’s needed to use K, which keeps the text matched so far out of the overall regex match.






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 14 at 20:19

























        answered May 14 at 19:51









        dessert

        19.6k55594




        19.6k55594






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1036251%2fbash-info-with-systemctl%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Unable to execute new pre-installation script (/var/lib/dpkg/tmp.ci/preinst)

            Running the scala interactive shell from the command line

            Do not install recommended packages of dependencies