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?