user2412714
user2412714

Reputation:

Writing the Terminal displayed output in a file

I'm trying to write the terminal displayed output in a file. Is there any pipe command to run the following two command at the same time but sequentially. So basically first it will run the first command and result of first command will be used in by second command. Now I'm running commands one after another.

python test_1_result.py > result_1.txt
python test_2_result.py > result_2.txt

Thanks in advance for any suggestion.

Upvotes: 2

Views: 99

Answers (3)

Requist
Requist

Reputation: 165

Simply at a semicolon (how I think it's called) between the two commands.

python test_1_result.py > result_1.txt ; python test_2_result.py > result_2.txt

Upvotes: 0

Carl Cook
Carl Cook

Reputation: 372

If you want to run both commands at the same time (where each process writes to a different file), just put the first command in the background:

python test_1_result.py > result_1.txt &
python test_2_result.py > result_2.txt

Upvotes: 1

SBI
SBI

Reputation: 2322

Do you mean you want to write the results into the same file? One after the other? Then use >> instead of >. The >> operator appends to a file instead of overwriting the complete content like > does.

In your case, the commands would be like this:

python test_1_result.py >> result.txt
python test_2_result.py >> result.txt

Upvotes: 1

Related Questions