Bash: info with systemctl

Clash 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: "?
command-line text-processing grep
add a comment |Â
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: "?
command-line text-processing grep
3
What do you want this information for? As noted in the man page,systemctl statusis intended to be human-readable: if you're going to start parsing/scripting it, you would likely be better off usingsystemctl showe.g.systemctl show ssh.service --property=ActiveState,SubState,ExecMainStartTimestamp
â steeldriver
May 14 at 20:10
ok, I read the properties but your string will getExecMainStartTimestamp=Mon 2018-05-14 22:11:37 CEST ActiveState=active SubState=runningon 3 lines
â Lilia
May 14 at 20:19
add a comment |Â
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: "?
command-line text-processing grep
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: "?
command-line text-processing grep
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 statusis intended to be human-readable: if you're going to start parsing/scripting it, you would likely be better off usingsystemctl showe.g.systemctl show ssh.service --property=ActiveState,SubState,ExecMainStartTimestamp
â steeldriver
May 14 at 20:10
ok, I read the properties but your string will getExecMainStartTimestamp=Mon 2018-05-14 22:11:37 CEST ActiveState=active SubState=runningon 3 lines
â Lilia
May 14 at 20:19
add a comment |Â
3
What do you want this information for? As noted in the man page,systemctl statusis intended to be human-readable: if you're going to start parsing/scripting it, you would likely be better off usingsystemctl showe.g.systemctl show ssh.service --property=ActiveState,SubState,ExecMainStartTimestamp
â steeldriver
May 14 at 20:10
ok, I read the properties but your string will getExecMainStartTimestamp=Mon 2018-05-14 22:11:37 CEST ActiveState=active SubState=runningon 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
add a comment |Â
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
-otellsgrepto print only the matched parts of a matching line-Penables Perl-compatible regular expressions (PCRE), thatâÂÂs needed to useK, which keeps the text matched so far out of the overall regex match.
add a comment |Â
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
-otellsgrepto print only the matched parts of a matching line-Penables Perl-compatible regular expressions (PCRE), thatâÂÂs needed to useK, which keeps the text matched so far out of the overall regex match.
add a comment |Â
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
-otellsgrepto print only the matched parts of a matching line-Penables Perl-compatible regular expressions (PCRE), thatâÂÂs needed to useK, which keeps the text matched so far out of the overall regex match.
add a comment |Â
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
-otellsgrepto print only the matched parts of a matching line-Penables Perl-compatible regular expressions (PCRE), thatâÂÂs needed to useK, which keeps the text matched so far out of the overall regex match.
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
-otellsgrepto print only the matched parts of a matching line-Penables Perl-compatible regular expressions (PCRE), thatâÂÂs needed to useK, which keeps the text matched so far out of the overall regex match.
edited May 14 at 20:19
answered May 14 at 19:51
dessert
19.6k55594
19.6k55594
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
3
What do you want this information for? As noted in the man page,
systemctl statusis intended to be human-readable: if you're going to start parsing/scripting it, you would likely be better off usingsystemctl showe.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=runningon 3 linesâ Lilia
May 14 at 20:19