What is the difference between $@ and $* in linux shell script? -


this question has answer here:

in book "linux shell scripting cookbook"

it says $@ expands $1, $2, $3 , on , $* expands $1c$2c$3, c first character of ifs.

what's difference between $@ , $* , ifs means?

ifs internal field separator, means shell recognises seperates words.

so run following command

ifs=$'\n' 

would cause shell recognise new lines seperators.

$ sign of being assigned variable

however numbers reserved script inputs.

so $1 variable input, $2 second variable input.

$@ of parameters passed script.

so if run command

bash command.sh bork woof meow 

this value of above listed variables

  $1 = bork   $2 = woof   $3 = meow   $@ = bork woof meow 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -