bug-bash
[Top][All Lists]
Advanced

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

Re: Not so useless use of cat


From: Bob Proulx
Subject: Re: Not so useless use of cat
Date: Tue, 16 Sep 2014 02:15:50 -0600
User-agent: Mutt/1.5.23 (2014-03-12)

Ralf Goertz wrote:
> Actually things are more complicated. I do need the /dev/stdout part. I
> obiously don't have the problem with `cat' but with some other program
> that doesn't write to stdout per se and expects a -o parameter for the
> output file. And this program just accepts one input file. I merely used
> the first `cat' in my example to make my point. So what I wanted was

I suspected that was the case.  That is generally the way it goes.

But does the program really have no way to write to stdout?  I despise
programs such as those.  They should be fixed so that there is a way
to use them as a filter.  Because working around those programs by
using Linux specific features such as /dev/stdout makes the entire
bundle non-portable to systems that don't have /dev/stdout.

> $ for i in file[12] ; do program -i "$i" -o /dev/stdout ; done > outfile
> 
> which I assumed to be elegant and would do as I expected except it
> didn't and I really thought it could have been a bug. That's why I
> reported it here.

I guess you could create as many temporary files as needed and then
concatenate them with cat afterward.  Or if the program can't be fixed
to append or write to stdout directly then use the not so useless cat
after all.  Probably needs a comment in that case though! :-)

There is another possibility.  I don't actually like this one as
much.  It seems more confusing.  It uses more processes.  But try this:

  for i in file[12] ; do program -i "$i" -o >(cat) ; done >outfile

Good luck!
Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]