From owner-freebsd-questions@FreeBSD.ORG Sun Jun 8 23:05:04 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 514CF37B405 for ; Sun, 8 Jun 2003 23:05:04 -0700 (PDT) Received: from truman.datasphereweb.com (12-212-67-226.client.attbi.com [12.212.67.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 5B59943F75 for ; Sun, 8 Jun 2003 23:05:01 -0700 (PDT) (envelope-from ryallsd@datasphereweb.com) Received: (qmail 29613 invoked from network); 9 Jun 2003 06:05:00 -0000 Received: from evrtwa1-ar17-4-47-114-001.evrtwa1.dsl-verizon.net (HELO bartxp) (4.47.114.1) by truman.datasphereweb.com with SMTP; 9 Jun 2003 06:05:00 -0000 From: "Derrick Ryalls" To: "'freebsd-questions'" Date: Sun, 8 Jun 2003 23:02:42 -0700 Message-ID: <001e01c32e4c$c0c19490$0200a8c0@bartxp> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4024 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal Subject: Shell line parse needed X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jun 2003 06:05:04 -0000 Thanks to help from here I have MRTG setup on a 4.7 server, but now I need help with parsing console info. I want a script to report CPU utilization by a specific process. When I type this: top | grep hlds it gives me: 60905 root 10 0 54960K 49736K nanslp 1:26 0.00% 0.00% hlds What I need is to get the last whole number before hlds, which should be cpu utilization. For instance, if the line was: 60905 root 10 0 54960K 49736K nanslp 1:26 4.61% 5.23% hlds I would need the script to report: 5 If no matching process is found, it should report 0. I was thinking of writing a C prog for this since that is the language I can use, but I am certain this could be a very small shell script. Thanks in advance. -Derrick