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.
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 ...
Get Linux Shells by Example 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.