Date: Fri, 29 Oct 2004 15:23:51 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Leroy van Logchem <leroy.vanlogchem@wldelft.nl> Cc: freebsd-questions@freebsd.org Subject: Re: How to make the output of ps(1) aware of tty / pipe? Message-ID: <20041029142351.GC47544@happy-idiot-talk.infracaninophile.co.uk> In-Reply-To: <418247B7.3000902@wldelft.nl> References: <418247B7.3000902@wldelft.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041029142351.GC47544>