开发者

ampersand at beginning of a line in csh

开发者 https://www.devze.com 2022-12-20 19:01 出处:网络
What does an ampersand at the beginning of a 开发者_Go百科line do in csh?It seems to be ignored (with no error message), but why?Found something interesting:

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


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?


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


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.

0

精彩评论

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