$$$$ Symbols in shell scripting

 


Special Variable

Description

$#

Number of positional parameters (arguments) passed to the script.

$?

Exit status of the last executed command. A value of 0 usually indicates success, and any non-zero value indicates an error.

$0

The name of the script or command that is being executed.

$1, $2, ...

The first, second, and subsequent positional parameters passed to the script. $1 is the first argument, $2 is the second, and so on.

$*

All the positional parameters passed to the script, treated as a single word.

"$@"

All the positional parameters passed to the script, treated as separate words. This preserves each parameter as a distinct word, even if they contain spaces.

$$

The process ID (PID) of the current shell or script.

$!

The process ID (PID) of the last background command.

$_

The last argument of the previous command.

$-

Current options set for the shell (e.g., options used when invoking the shell with flags like -x, -v, etc.).

$()

Command substitution: Executes the command inside the parentheses and returns its output. For example, $(date) would return the current date.

${}

Parameter expansion: Used to retrieve or manipulate the value of a variable. For example, ${var} gives the value of var.

 

 

Comments

Popular posts from this blog

AWK : Commands

CURL Commands