2

Say, I have a program called "tree". It takes as input a text file containing some dictionary of English words, call it engDict.txt.

In my terminal, I would execute this program using the following command:

>> ./tree engDict.txt

Assuming this program automatically reads in the file and processed it. Then, it prompts the user: Would you like to exit the program (y/n)?

Now, my question is:

How can I send input to this program in one line?

For example, I tried the following, but it doesn't do what I'd like.

>> ./tree engDict.txt | n

or

>> ./tree engDict.txt ; n
2
  • 2
    You don't really need the c++ tag there. This is basically a nix question. Commented Aug 22, 2017 at 21:42
  • @Matt My bad. It was a suggested tag so I added it. Commented Aug 22, 2017 at 23:23

1 Answer 1

2

Close. The letter n should be written to the input.

  echo n | ./tree engDict.txt
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.