O'Reilly logo

Linux Shells by Example by Ellie Quigley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.9. Special Variables and Modifiers

Built into the TC shell are several variables consisting of one character. The $ preceding the character allows variable interpretation. See Table 10.21.

Table 10.21. Variables and Their Meanings
Variable Example Meaning
$?var echo $?name Returns 1 if variable has been set, 0 if not.
$#var echo $#fruit Prints the number of elements in an array.
$%var echo $%name Prints number of characters in a variable or array.
$$ echo $$ Prints the PID of the current shell.
$< set name = $< Accepts a line of input from user up to newline.
$? echo $? Same as $status. Contains the exit status of the last command.
$! kill $! Contains the process id number of the last job put in the background.
Example ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required