Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between echo and @echo in unix shells

What's the difference between "echo" and "@echo" in the unix world?

I can't even google special characters.

For example, as used here

like image 915
Mako Avatar asked Apr 11 '15 10:04

Mako


People also ask

What is the difference between echo and echo >>?

When echoing something to a file, >> appends to the file and > overwrites the file.

What is the difference between echo and printf in Unix?

Printf provides for the creation of a formatting string and offers a non-zero quit status when it fails. Whereas echo normally leaves with a 0 status and typically outputs inputs headed by the end of line character upon this standard result. The “printf” gives you more options for the output format than the “echo”.

What is difference between $@ and $* in shell?

There is no difference if you do not put $* or $@ in quotes. But if you put them inside quotes (which you should, as a general good practice), then $@ will pass your parameters as separate parameters, whereas $* will just pass all params as a single parameter.

What is the difference between $* and $# in Unix?

So basically, $# is a number of arguments given when your script was executed. $* is a string containing all arguments. For example, $1 is the first argument and so on. This is useful, if you want to access a specific argument in your script.


1 Answers

That's a Makefile-specific thing; it has nothing to do with shell scripts.

Recipes that begin with @ do not echo the command. That is to say, with a Makefile

foo:
    echo foo

You get

$ make foo        # <-- this is meant to be the command you enter in the shell
echo foo
foo

Whereas with a Makefile

foo:
    @echo foo

it is

$ make foo
foo
like image 173
Wintermute Avatar answered Oct 11 '22 19:10

Wintermute