What do $#, $1 and $2 mean?
<p>My question is about a bash-programme, which is in this big book about programming a raspberry pi (bash, Python, C).</p>

<p>There is a sample programme to show how the <em>if</em> works in bash, but no matter how many times a read through the description of the programme, it just doesn't seem to explain properly what it does (I know it's too much to ask if I want a thorough bash tutorial in a 1000 pages book, and that's why I'm here)</p>

<p>So here is the code:</p>

<pre><code>#!/bin/bash

if test $# -ne 2; then
    echo "You have to pass 2 arguments to the command"
    #argument / parameter, whatever you prefer
    exit 1
else
    echo "Argument 1: $1, argument 2: $2"
fi
</code></pre>

<p>I understand, that the <code>-ne 2</code> means: not equal to 2, so it checks if the <code>$#</code> is equal to 2, but I don't understand what it does (the <code>$#</code>). -> First question</p>

<p>In the <code>else</code> it prints the <code>$1</code> and <code>$2</code>, but I thought that <code>$variablename</code> would print the value of that variable. How can an integer be a variable? -> second question</p>

<p>And yes, I google'ed and didn't find anything of use (maybe didn't search enough?), which is exactly why I'm here.</p>

<p>I would appreciate any kind of help, be it a link to read it myself, or a short explanation.
Thanks in advance :)</p>