Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I run a program in bash in such a way that first it receives some input from a file, and then, as the file ends, it will receive input from terminal?

share|improve this question
And also, how can I receive first input not from a file, but from a constant, like this: somecommand <<< "someinput"? – Septagram Nov 8 '11 at 18:57
up vote 1 down vote accepted
  1. cat myfile - | program


    cat myfile /dev/stdin | program
  2. Use echo, which has the same end result:

    (echo "someinput"; cat) | program
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.