Re-assigning parameters with set

You can re-assign parameters using the set command. Remember the set command shows us all our shell variables. set can also be used to assign parameters:

set a b c
            

and then

$1 would be equal to a
$2 would be equal to b
$3 would be equal to c
            

Notice that if you do this, you overwrite any of your positional parameters that $1, $2 and $3 may have contained previously.

If you were to create a script called superfluous.sh:

#!/bin/bash
echo Command line positional parameters: $1 $2 $3
set a b c
echo Reset positional parameters: $1 $2 $3
exit 0
            

and run it with:

chmod +x superfluous.sh

./superfluous.sh one two three
            

You will get the output

Command line positional parameters: one two three

Reset positional parameters: a b c
            

The set command, has overwritten your command line positional parameters that you sent from your prompt. It's worth noting that if you need to reset positional parameters then this is the ONLY way to do it.