开发者

Shortening Bash output command

Is there a more efficient way to output a comman开发者_StackOverflow中文版d than this:

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


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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜