what is $$ S$ $# in shell scripting

Hi experts,

I have a shell script named put.sh which has a for loop statement

for i in `cat $1`
do
.....
done

what is $1 here?

also what is $$ & $# in shell scripting?

Thanks

That is almost always the wrong way to read a file; it does not read it one line at a time -- it reads it one word at a time. Use a while loop:

while IFS= read -r line
do
   : do something with "$line"
done < "$1"

The first argument to the script. E.g.:

put.sh whatever

In the script, $1 has the value "whatever".

Read the "Special Parameters" section of your shell man page.

$$ is the ID of the current process.

$# is the number of arguments on the command line.

Thank you

$1 is the first argument ..which means

put.sh anyfilename

anyfilename takes $1 right?