Re: how to use variables to build pipes?

From: aryzhov (aryzhov_at_my-deja.com)
Date: 11/29/04


Date: 29 Nov 2004 00:16:17 -0800

Claus Atzenbeck <claus.atzenbeck@freenet.de> wrote in message news:<coe1qh$jmn$1@ngspool-d02.news.aol.com>...
> Hello,
>
> I have a bash shell script, but I don't come along well:
>
> ************************
> OUTPUTFILE="$HOME/Library/Logs/mx"
> OUTPUT="sed 's/something/nothing/g' | tee -a $OUTFILE"
>
> echo "something" | $OUTPUT
> cat blah.txt | $OUTPUT
> ...
> ************************
>
> Writing
> echo "something" | "$OUTPUT"
> does not help either.
>
> Where is the bug?
>

It's not the bug, it's how most shells work.
Try to use eval:

#!/bin/sh
#
#
# OUTPUT="sort | uniq -c"
# INPUT="
> aaa
> bbb
> bbb
> ccc
> aaa
> aaa
> ccc
> "
#
#
# echo "$INPUT" | sort | uniq -c
   2
   3 aaa
   2 bbb
   2 ccc
#
#
#
# echo "$INPUT" | eval "$OUTPUT"
   2
   3 aaa
   2 bbb
   2 ccc
#
#



Relevant Pages

  • Re: Re : After upgrading to 2.6.8.1, k3b stopped working
    ... Paul Howarth wrote: ... >>The 2.6.8 kernels have a bug which prevents them from writing to CDs. ...
    (Fedora)
  • Re: Re : After upgrading to 2.6.8.1, k3b stopped working
    ... > The 2.6.8 kernels have a bug which prevents them from writing to CDs. ... I'd describe it more as the older kernels have a bug that allows regular ... users to destroy their IDE drives. ...
    (Fedora)
  • Re: Bug in CFrameWnd::OnInitMenuPopup (MFC 7.10)
    ... > Writing a KB article is not a easy thing. ... > tech review, content review...... ... customers reported to us, but which we could not reproduce. ... I carefully documented this bug in a posting to this newsgroup, ...
    (microsoft.public.vc.mfc)
  • Re: [Diehard] Overlap sum test
    ... > I guess the attention is due to the AES, not to a possibly bug in DH. ... > should suggest a total re-check of DH and the writing of the documentation ...
    (sci.crypt)
  • Re: To Beale Screamer: FreeMe
    ... > Methinks something is writing to memory it should be leaving damn well ... a PRNG for your platform and use that for functions that need a PRNG ... As for the "heap overwritten" bug I'm not sure exactly. ...
    (sci.crypt)