Reputation: 2796
Is there a more efficient way to output a command than this:
whereis python > test.txt;date >> test.txt;who >> test.txt
Upvotes: 3
Views: 217
Reputation: 86333
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
Upvotes: 3