

$* and are special bash parameters and if used without double quotes then both will behave identical i.e.
#Bash script example for running java classes mac full#
bashparameterexample.sh 23 44 $1=23 $2=44ĭifference between $* and bash parameters $* and both are used to access full list of positional parameters supplied during invocation of bash script and you can iterate through them using bash for loop. $* (dollar star) this is similar to special bash parameter only difference is when expansion occurs with double quotes, it expands to a single word with the value of each bash parameter separated by the first character of the IFS special environment ~ $. When expansion occurs inside double-quotes, every parameter expands into separate words. This bash parameter is also used to hold the name of mail file while checking (dollar at the rate) bash parameter is used to expand into positional parameters starting from one. $_ (dollar underscore) is another special bash parameter and used to reference the absolute file name of the shell or bash script which is being executed as specified in the argument list. By using this you can check whether your bash script is completed successfully or not. $0 is one of the most used bash parameters and used to get the exit status of the most recently executed command in the foreground.


Though this bash parameter is rarely used. $- (dollar hyphen) bash parameter is used to get current option flags specified during the invocation, by the set built-in command or set by the bash shell itself.

so you can use this if you want to print the name of shell script. $0 bash parameter is used to reference the name of the shell or shell script. $# is quite a special bash parameter and it expands to a number of positional parameters in decimal. $$ is used to reference the process ID of bash shell itself $! bash script parameter is used to reference the process ID of the most recently executed command in background. Special bash parameters and their meaning Special bash parameter This list of special bash parameters is by no means complete and only contains some of the bash script parameters which I have encountered, so please contribute any bash parameter which is not in this list and you found useful. The list which I am going to share with you guys today is what I have accumulated over the years. This bash script parameter tutorial is in continuation of my earlier UNIX tutorials find examples in UNIX, grep command examples in UNIX, and UNIX networking commands tutorial if you haven’t read already you may find them interesting and useful. I did know that they are bash parameter and has special meaning but I don't have all meanings of special bash parameter on top of my head and I always go to Google and search endlessly for those special bash parameter, sometimes I got and found the meaning of those special bash script parameters quickly but sometimes I need to spend some time to get what I am actually looking for, so I thought to document meanings and expansion of those special bash parameters or bash script parameters. When I was new to the bash shell and Linux and looking for some already written bash script I used to get baffled with special bash symbols like $_, $1, etc. Many of us use a bash script for doing housekeeping and other stuff but occasionally and not much aware of special bash parameters. Meaning of bash parameter used in Unix script
