From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 7 17:27:25 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 81CC5106566C for ; Wed, 7 Jan 2009 17:27:25 +0000 (UTC) (envelope-from sheldon@sigsegv.ca) Received: from wf-out-1314.google.com (wf-out-1314.google.com [209.85.200.172]) by mx1.freebsd.org (Postfix) with ESMTP id 5D5958FC16 for ; Wed, 7 Jan 2009 17:27:25 +0000 (UTC) (envelope-from sheldon@sigsegv.ca) Received: by wf-out-1314.google.com with SMTP id 24so11143717wfg.7 for ; Wed, 07 Jan 2009 09:27:24 -0800 (PST) Received: by 10.142.224.5 with SMTP id w5mr1213972wfg.206.1231349244711; Wed, 07 Jan 2009 09:27:24 -0800 (PST) Received: by 10.142.199.18 with HTTP; Wed, 7 Jan 2009 09:27:24 -0800 (PST) Message-ID: Date: Wed, 7 Jan 2009 09:27:24 -0800 From: "Sheldon Givens" To: freebsd-hackers@freebsd.org In-Reply-To: <20090107154854.GC1462@roadrunner.spoerlein.net> MIME-Version: 1.0 References: <20090107125759.GA1462@roadrunner.spoerlein.net> <20090107154854.GC1462@roadrunner.spoerlein.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: Small change to 'ps' X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jan 2009 17:27:25 -0000 On Wed, Jan 7, 2009 at 7:48 AM, Ulrich Spoerlein wrote: > On Wed, 07.01.2009 at 08:54:41 -0600, Sean C. Farley wrote: > > On Wed, 7 Jan 2009, Ulrich Spoerlein wrote: > > > > > On Tue, 06.01.2009 at 11:52:39 -0800, Sheldon Givens wrote: > > >> Hello everyone, > > >> > > >> It occurs to me that FreeBSD ps lacks the ability to disable header. > > >> This seems like a really obvious feature, and I may have simply > > >> missed it's existence (despite my relentlessly searching the man > > >> page) but here is a small patch that sets the flag 'n' to disable > > >> header output. > > > > > > You've missed it, probably because it is non-obvious: > > > > > > % ps -p 1 -o pid,cpu > > > PID CPU > > > 1 0 > > > % ps -p 1 -o pid= -o cpu= > > > 1 0 > > > % > > > > Another way: > > ps | tail +2 > > I'm not sure about the portability of tail +N, I seem to remember that > AIX doesn't support it. Therefore I'd rather use > > % ps | sed 1d > > which is way more portable. > > Cheers, > Ulrich Spoerlein > -- > It is better to remain silent and be thought a fool, > than to speak, and remove all doubt. > Hello everybody, Ulrich: I appreciate your solution, but it ends up being a pretty ridiculous command when you start desiring 6 or 7 fields. Sean: Ulrich is right in saying that tail +val is unreliable when coding for portability. And I guess I just feel like running a second command to do what should be possible to do with the first command (and is, on many platforms. ps --no-headers on linux for example) is a problem and presents opportunity for continued refinement of the utility. Sheldon