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

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



 --- Adam Funk <a24061@yahoo.com> wrote: 

> On Tuesday 18 May 2004 10:20, Thomas Adam wrote:
> 
> >  --- Adam Funk <a24061@yahoo.com> wrote:
> > 
> >> (Sorry about the long lines but they illustrate the output I'm
> >>  talking about.)
> >> 
> >> ``dpkg -l'' on its own in a terminal produces wide output, e.g.:
> > 
> > COLUMNS=200 dpkg -l | pipe | pipe | pipe | more | more | yay
> > 
> > Change the value of 200, if it is too small.
> 
> 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. Either you need to use process substitution or NOT run it in a
subshell, as per my example in a previous e-mail.

-- Thomas Adam

=====
"The Linux Weekend Mechanic" -- http://linuxgazette.net
"TAG Editor"                 -- http://linuxgazette.net

"<shrug> We'll just save up your sins, Thomas, and punish 
you for all of them at once when you get better. The 
experience will probably kill you. :)"

 -- Benjamin A. Okopnik (Linux Gazette Technical Editor)


	
	
		
Chat instantly with your online friends?  Get the
FREE Yahoo! Messenger http://uk.messenger.yahoo.com/



Reply to: