Built-In Variables
Built-in variables are special variables that Linux provides to you that can be used to make decisions within a program. You cannot modify the values of these variables within the shell program.
Some of these variables are
$# | Number of positional parameters passed to the shell program |
$? | Completion code of the last command or shell program executed within the shell program (returned value) |
$0 | The name of the shell program |
$* | A single string of all arguments passed at the time of invocation of the shell program |
To show these built-in variables in use, here is a sample program called mypgm2:
#!/bin/sh #my test program echo "Number of parameters is "$# echo "Program name is "$0 echo "Parameters as a single string is "$*
If ...
Get Red Hat® Linux® 7 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.