[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Getting wide ``dpkg -l'' output in scripts and pipes.



On Tue, May 18, 2004 at 01:18:50PM +0100, Thomas Adam wrote:
>  --- Adam Funk <a24061@yahoo.com> wrote: 
> > Excellent.  I had tried these:
> > 
> > (COLUMNS=200 ; dpkg -l) |head
> > (COLUMNS=200 && dpkg -l) |head
> > 
> > but got the narrow output.  Why do these two fail?
> 
> Because COLUMNS=200 is being set in a subshell. Thus, the resultant output
> when it is piped through to head is lost, since bash does not work in this
> way.

No; it doesn't matter whether head can see COLUMNS or not, and the
output is not "lost". You can tell this because both of these work fine:

  (export COLUMNS=200; dpkg -l) | head
  (COLUMNS=200 dpkg -l) | head

... as well as the more natural:

  COLUMNS=200 dpkg -l | head

Cheers,

-- 
Colin Watson                                  [cjwatson@flatline.org.uk]



Reply to: