【发布时间】:2010-12-19 10:20:28
【问题描述】:
有没有比这更有效的命令输出方式:
whereis python > test.txt;date >> test.txt;who >> test.txt
【问题讨论】:
有没有比这更有效的命令输出方式:
whereis python > test.txt;date >> test.txt;who >> test.txt
【问题讨论】:
怎么样:
{ whereis python; date; who; } > test.txt
编辑:
{...} 表示法指示bash 在当前 shell 中启动这些命令,而不是像使用 (...) 表示法时那样使用子 shell。由于避免创建新流程,因此效率稍高。
如果您想临时更改命令的环境(工作目录、变量等),(...) 表示法更易于使用,因为您不必事后手动恢复所有更改:
( whereis python; date; who ) > test.txt
【讨论】:
(whereis python; date; who) >test.txt
【讨论】: