ampersand at beginning of a line in csh

十年热恋 提交于 2019-12-22 10:21:38

问题


What does an ampersand at the beginning of a line do in csh? It seems to be ignored (with no error message), but why?


回答1:


Found something interesting:

The semicolon (;) character separates successive commands on a single command line. For example,

% <command1> ; <command2>

executes <command1>, and when it finishes, <command2> gets executed.

The ampersand character (&) is similar to the semicolon (;) but does not wait for <command1> to finish.

Maybe it's treating it like an empty command?




回答2:


The best way to answer will be example. Taking idea of JoelFAn ahaed:

EXAMPLE 1

user$ date ; sleep 5s ; date

Thu Apr 5 10:46:45 IST 2012

Thu Apr 5 10:46:50 IST 2012

EXAMPLE 2

user$ date & sleep 5s & date

[1] 18371

[2] 18372

Thu Apr 5 10:47:09 IST 2012

Thu Apr 5 10:47:09 IST 2012

[1] - Done date

EXAMPLE3

user$ bg

[2] sleep 5s &

The examples are self explanatory.

Thanks




回答3:


I can't find anything in csh docs about it. However, I know in make it suppresses any output from the command (but still runs it). Perhaps that's what it is doing.



来源:https://stackoverflow.com/questions/2314726/ampersand-at-beginning-of-a-line-in-csh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!