缩短Bash输出命令
是否有比此更有效的方法输出命令:缩短Bash输出命令,bash,shell,terminal,Bash,Shell,Terminal,是否有比此更有效的方法输出命令: whereis python > test.txt;date >> test.txt;who >> test.txt 那么: { whereis python; date; who; } > test.txt 编辑: {…}表示法指示bash在当前shell中启动这些命令,而不是像使用(…)表示法那样使用子shell。它的效率稍高一些,因为它避免了创建新流程 但是,如果您想临时更改comamnds的环境(工作目录、变量等)
whereis python > test.txt;date >> test.txt;who >> test.txt
那么:
{ whereis python; date; who; } > test.txt
编辑:
{…}
表示法指示bash
在当前shell中启动这些命令,而不是像使用(…)
表示法那样使用子shell。它的效率稍高一些,因为它避免了创建新流程
但是,如果您想临时更改comamnds的环境(工作目录、变量等),则(…)
符号更易于使用,因为您不必在之后手动恢复所有更改:
( whereis python; date; who ) > test.txt
( whereis python; date; who ) > test.txt