theshell.ch/site/pages/scripts/2-special-variables.html
terehm c0a6a75fce css-team: spellcheck
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@280 a672b425-5310-4d7a-af5c-997e18724b81
2018-11-19 15:05:42 +00:00

36 lines
1019 B
HTML

---
layout: page
category-page: scripts
category-title: Scripting
tags: variables special $ !
author: Dario Rasic
title: Script Special Variables
previous-page: pages/scripts/1-variables.html
next-page: pages/scripts/3-parameter_expansion.html
---
<!-- Intro -->
There are certain strings that we can't use in the variable-naming process.<br>
In this page we will see what those strings are, and what their purpose is.<br>
<h4>$$</h4>
To begin, we look at the simplest variable, which is the dollar sign ($).
This command simply gives us the process ID of the current shell.<br>
<pre>
echo $$
11480
</pre>
<h4>$0</h4>
This variable simply gives us the filename of the current script.
<h4>$n</h4>
This variable corresponds to the arguments with which a script was invoked.
Here n is a positive number corresponding to the position of an argument.
<h4>$#</h4>
This variable gives us the number of arguments supplied to a script.
<h4>$!</h4>
This variable gives us the process ID of the last background command.