ampersand at beginning of a line in csh

2019-05-09 22:09发布

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

3条回答
戒情不戒烟
2楼-- · 2019-05-09 22:34

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楼-- · 2019-05-09 22:36

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?

查看更多
Lonely孤独者°
4楼-- · 2019-05-09 22:36

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.

查看更多
登录 后发表回答