zsh-workers
 help / color / mirror / code / Atom feed
From: Cary Lewis <cary.lewis@gmail.com>
To: zsh-workers@zsh.org
Subject: tee stdin and grep without creating a temp file
Date: Wed, 23 Oct 2013 14:46:34 -0400	[thread overview]
Message-ID: <CAEF1h+Vtag-e_rz6DLe8OWy9h=boxFD69VOT-q5w6+OZ49iVRQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 569 bytes --]

I have a situation where I need to grep an stdin input stream, and based on
whether I find a certain pattern, take appropriate action. The action
involves processing the stdin stream again.

I solved this by simply copying the stdin stream to a temporary file, and
then grepping the temp file, and then using the temp file later on in the
script.

But this is not very elegant. I tried to create a fifo with mkfifo, and tee
the stdin to the pipe and then grep on the output of the tee. This approach
doesn't work correctly.

Does anyone have an elegant way to do this?

             reply	other threads:[~2013-10-23 18:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-23 18:46 Cary Lewis [this message]
2013-10-25  1:16 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEF1h+Vtag-e_rz6DLe8OWy9h=boxFD69VOT-q5w6+OZ49iVRQ@mail.gmail.com' \
    --to=cary.lewis@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).