Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

Example:

& echo 'hi there'

performs the expected echo with no error message.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

It's backgrounding "nothing". The ampersand also functions as a command delimiter like ;.

You'll find that

; echo 'hi there'

does (in this case) essentially the same thing.

These, however, are different:

sleep 10 ; echo 'hi' & echo 'there'
sleep 10 ; echo 'hi' ; echo 'there'
share|improve this answer
add comment

It behaves this way because that's how the implementors of CSH decided it should be treated.

Seems like the csh family shells behave like this while the Bourne family of shells throw an error (since it is likely to be an input error)

share|improve this answer
    
But what's the logic of it? –  JoelFan Feb 23 '10 at 16:58
    
See Dennis's answer for the 'logic' of it. –  MikeyB Feb 24 '10 at 2:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.