From owner-freebsd-questions@FreeBSD.ORG Fri Oct 29 14:24:04 2004 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 150B716A4CE for ; Fri, 29 Oct 2004 14:24:04 +0000 (GMT) Received: from smtp.infracaninophile.co.uk (ns0.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 095C043D1F for ; Fri, 29 Oct 2004 14:24:03 +0000 (GMT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost.infracaninophile.co.uk [IPv6:::1])i9TENph5048322 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 29 Oct 2004 15:23:51 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)i9TENpb0048321; Fri, 29 Oct 2004 15:23:51 +0100 (BST) (envelope-from matthew) Date: Fri, 29 Oct 2004 15:23:51 +0100 From: Matthew Seaman To: Leroy van Logchem Message-ID: <20041029142351.GC47544@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Leroy van Logchem , freebsd-questions@freebsd.org References: <418247B7.3000902@wldelft.nl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="CblX+4bnyfN0pR09" Content-Disposition: inline In-Reply-To: <418247B7.3000902@wldelft.nl> User-Agent: Mutt/1.4.2.1i X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.5.6 (smtp.infracaninophile.co.uk [IPv6:::1]); Fri, 29 Oct 2004 15:23:52 +0100 (BST) X-Virus-Scanned: clamd / ClamAV version devel-20040904, clamav-milter version 0.75l on smtp.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.8 required=5.0 tests=ALL_TRUSTED,AWL autolearn=ham version=3.0.1 X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on happy-idiot-talk.infracaninophile.co.uk cc: freebsd-questions@freebsd.org Subject: Re: How to make the output of ps(1) aware of tty / pipe? 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: Fri, 29 Oct 2004 14:24:04 -0000 --CblX+4bnyfN0pR09 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 29, 2004 at 03:37:59PM +0200, Leroy van Logchem wrote: > How to make the output of 'ps aux' for example aware of the output being= =20 > piped trough grep? > Now it breaks the lines while I would expect it to be just long lines. > (I don't want to loose the linebreaking feature by using a -ww alias or= =20 > something) Errr... that's what the -w flag to ps(1) is for. Without the -w flag, ps assumes it is printing to an 80 column terminal, and truncates the lines appropriately. With one -w flag, it assumes a 132 column terminal, and with more than one -w flag, ps assumes an unlimited number of columns are available. It does that whether or not the output is being displayed on the tty, written to a file or fed into a pipe. (Unlike, say, less(1), top(1) or ls(1) which can change their behaviour according to circumstances). Don't be confused by the line wrapping feature of the terminal: the output might look like it's split over several lines, but really it isn't. Compare and contrast the effects of: % ps -auxww | less % ps -auxww | less -S (Try hitting the left and right arrow keys while paging through the second set of output...) Generally, if you're grepping through the output of ps(1), you want all of the ps output to be there. The usual idiom is: % ps -auxww | grep foo Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --CblX+4bnyfN0pR09 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQFBglJ3iD657aJF7eIRAvb0AKCaZ32DyaNGpIlJlVA3gp+uRXtTUACeL/mg zCdVx95vf196qX+NB0fnb8Q= =q5Cg -----END PGP SIGNATURE----- --CblX+4bnyfN0pR09--