[CentOS] parsing out adjacent text

Patrick Bervoets patrick.bervoets at psc-elsene.be
Tue Jun 3 13:29:45 UTC 2014


op 03-06-14 15:18, schreef Tim Dunphy:
>   [root at uszmpwslp014lc ~]# GET http://$(hostname -i)/server-status  | grep
> -i  requests/sec
> <dt>4.08 requests/sec - 80.9 kB/second - 19.8 kB/request</dt>
>
>
> That works ok. And next I'm grepping it back down and awking it to just the
> part I'm interested in:
>
> [root at uszmpwslp014lc ~]# GET http://$(hostname -i)/server-status  | grep -i
> -e request -e requests/sec | grep -i -v -e currently  -e code  -e ss | awk
> '{print $1}'
> <dt>4.08
>
> But now I need to get rid of just the <dt> in front of the 4.08?
cut --delimiter=">" --field=2

you could even get rid of the awk and pipe your grep to cut --delimiter=">" --field=2 | cut --delimiter=" " --field=1

But there are many different ways to solve this.

greetings
Patrick



More information about the CentOS mailing list