3

Is there a more efficient way to output a command than this:

whereis python > test.txt;date >> test.txt;who >> test.txt

2 Answers 2

3

How about:

{ whereis python; date; who; } > test.txt

EDIT:

The {...} notation instructs bash to launch these commands in the current shell, rather than use a subshell as would be the case if the (...) notation was used. It is slightly more efficient as it avoids creating a new process.

If you want to temporarily change the environment (working directory, variables etc) for the comamnds, though, the (...) notation is simpler to use, since you don't have to manually revert all changes afterwards:

( whereis python; date; who ) > test.txt
Sign up to request clarification or add additional context in comments.

Comments

1
(whereis python; date; who) >test.txt

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.