Hi, I only know basic bash —just enough to get by for my day-to-day needs.
Basically I am learning Java at Uni, and they want example outputs.
Code:
java MyProgram | tee output.txt
is what I'm using at the moment, but this only grabs the STDOUT, but not the STDIN data I'm typing into the file.
Is there a way to get both STDIN and OUT into the same file, in the correct place?
a simple (stupidly pointless) example to show what I mean; say MyProgram simply asks for your favourite number, and you type in '5':
Code:
$ java MyProgram | tee output.txt && echo "#####" && cat output.txt
Welcome.
Enter your favourite number: 5
You entered: 5
Thank You.
#####
Welcome.
Enter your favourite number: You entered: 5
Thank You.
As you can see, output.txt only contains the STDOUT, no input, and generally there wasn't a newline.
Whereas I would like to include the STDIN in the file
Code:
$ java MyProgram {some code} | tee output.txt && echo "#####" && cat output.txt
Welcome.
Enter your favourite number: 5
You entered: 5
Thank You.
#####
Welcome.
Enter your favourite number: 5
You entered: 5
Thank You.
As you can see the input was recorded into the file too, including the newline character.
If this isn't possible from this way of thinking, perhaps if there is a command which copies everything — like a print screen, but for the command line?
I honestly have not idea, any insight and guidance will be much appreciated.
Thank You.