user3875388
user3875388

Reputation: 573

grep doesn't work as I think

I want to check if parsoid service is running. So I run this command:

service --status-all|grep 'parsoid'

But the result is:

 [ ? ]  aliyun-rdate

 [ ? ]  console-setup

 [ ? ]  dns-clean

 [ ? ]  irqbalance

 [ ? ]  killprocs

 [ ? ]  kmod

 [ ? ]  mysql

 [ ? ]  networking

 [ ? ]  ondemand

 [ ? ]  pppd-dns

 [ ? ]  rc.local

 [ ? ]  sendsigs

 [ ? ]  umountfs

 [ ? ]  umountnfs.sh

 [ ? ]  umountroot

Why? shouldn't grep be able to speak parsoid screened out of it?

Upvotes: 1

Views: 121

Answers (1)

Jahid
Jahid

Reputation: 22428

Try:

service --status-all 2>&1|grep -o 'parsoid'

1 is stdout and 2 is stderr.

> is for redirection

& specifies that what follows is a file descriptor (not a filename)

2>&1 redirects stderr to stdout and then the stdout is piped into the grep

Note: service --status-all writes to stderr.

Upvotes: 2

Related Questions