Special Parameters Flashcards

1
Q
  • asterisk
A

The positional parameters starting from the first. When used inside doublequotes (see quoting), like “$*”, it expands to all positional parameters as one word, delimited by the first character of the IFS variable (a space in this example): “$1 $2 $3 $4”.
If IFS is unset, the delimiter used will be always a space, if IFS is NULL, the delimiter will be nothing, which effectively concatenates all the positional parameters without any delimiter.
When used unquoted, it will just expand to the strings, one by one, not preserving the word boundaries (i.e. word splitting will split the text again, if it contains IFS characters.
See also the scripting article about handling positional parameters. https://web.archive.org/web/20230318164746/https://wiki.bash-hackers.org/scripting/posparams

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

@ at-sign

A

The positional parameters starting from the first. When used inside doublequotes (see quoting), like “$@”, it expands all positional parameters as separate words: “$1” “$2” “$3” “$4”
Without doublequotes, the behaviour is like the one of * without doublequotes.
See also the scripting article about handling positional parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

hash mark

A

Number of positional parameters (decimal)
See also the scripting article about handling positional parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

? question mark

A

Status of the most recently executed foreground-pipeline (exit/return code)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  • dash
A

Current option flags set by the shell itself, on invocation, or using the set builtin command. It’s just a set of characters, like himB for h, i, m and B.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

$ dollar-sign

A

The process ID (PID) of the shell. In an explicit subshell it expands to the PID of the current “main shell”, not the subshell. This is different from $BASHPID!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

! exclamation mark

A

The process ID (PID) of the most recently executed background pipeline (like started with command &)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

0 zero

A

The name of the shell or the shell script (filename). Set by the shell itself.
If Bash is started with a filename to execute (script), it’s set to this filename. If started with the -c <CMDLINE> option (commandline given as argument), then $0 will be the first argument after the given <CMDLINE>. Otherwise, it is set to the string given on invocation for argv[0].
Unlike popular belief, $0 is not a positional parameter.</CMDLINE></CMDLINE>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

_ underscore

A

A kind of catch-all parameter. Directly after shell invocation, it’s set to the filename used to invoke Bash, or the absolute or relative path to the script, just like $0 would show it. Subsequently, expands to the last argument to the previous command. Placed into the environment when executing commands, and set to the full pathname of these commands. When checking mail, this parameter holds the name of the mail file currently being checked.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly