I don't know what the question was, but here is an answer: >>>>>START>>>>> #!/bin/sh # ipr.sh - input pipe redirection. echo truncating tempfile.txt > tempfile.txt echo redirecting stdin to a tempfile.txt cat >> tempfile.txt echo printing tempfile.txt cat tempfile.txt echo setting stdin to tempfile.txt exec < tempfile.txt echo printing stdin cat <<<<<<END<<<<<<