на главную | войти | регистрация | DMCA | контакты | справка | donate |      

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Э Ю Я


моя полка | жанры | рекомендуем | рейтинг книг | рейтинг авторов | впечатления | новое | форум | сборники | читалки | авторам | добавить



4.12.1.2. Special variables

There are several special parameters , or special variables , that bash sets automatically; Table 4-17 contains a list of the most important ones.

Table 4-17. Important special variables

Name Description Notes
$$ Process ID of the shell Since process IDs are unique (at any one point in time), this can be used to ensure unique filenames (e.g., /tmp/$$.txt will never conflict with the same filename used by another copy of the same script).
$0 Name of the script Useful to generate error messages, and when one script is invoked through more than one name.
$1, $2, $3, ... Arguments given on the script's command line The shift command will eliminate $1 and then shift all of the parameters accordingly ($2 becomes $1, $3 becomes $2, and so forth).
$# Number of arguments from the script's command line If $# is 0, then no options were given on the command line.
$* $@ All of the arguments from the script's command line When quoted, "$*" becomes a single block of text containing all of the arguments, while "$@" becomes separate words. If the script is called with the arguments "green" and "yellow", then "$*" would evaluate to "green yellow", while "$@" would evaluate to "green" "yellow".
$? Exit status of the last command Manpages document the possible exit-status values for most commands.


4.12.1.1. Shell and environment variables | Fedora Linux | 4.12.1.3. Control structures