Help with commands

Hi again guys, today i bring to you new doubts, let me show the first example

#!/bin/bash
# ligass: lista archivos que son enlace simb�lico o tienen enlaces hard
# simb�licos: en ls -l se busca que empiece con l
if [ ! -d $1 ]
then
  echo Error: ligas: $1 no es un directorio
  exit

On the line of condition i can't figure out which is the function of $1, when, and for what i can use it.

other example.

TARGET=$1
DAYS=$2
SUBJECT=$3

Any one who has patience to explain to me?
Thanks

Are you passing any variable to the scripts...??

such as...

sh script.sh 54

In above example $1 = 54, same as if you have passed more than one variable it will be named as $2, $3 and so on....

You have a script - call it: script.sh.

When you type the name of the script you feed it extra words, called parameters.
The first one is $1, the second one is $2, so the third one is ??

#!/bin/bash
# myscript.sh
echo " \$1 is $1"
echo " \$2 is $2"

run the script

> ./myscript.sh dog cat
 $1 is dog
 $2 is cat
>

Guys thanks a lot again, i'm learning to much with you, now, i have a question for you, if my script didn't have parameters; which will be de value of $1?

Nothing. It will be blank.

You could have easily tried this and seen.

Perfect, i'll try it!

Next time, find another subject title or you will get an infraction (read the rules again...)

Sorry, it won't happend again