scripting examples

All posts tagged scripting examples by Linux Bash
  • Posted on
    Featured Image
    Positional parameters are variables in a bash script that hold the value of input arguments passed to the script when it is executed. These parameters are automatically assigned by Bash and are named $1, $2, $3, etc., corresponding to the first, second, third, and subsequent arguments. How do you normally access these positional parameters? In a Bash script, you can directly access the first nine parameters using $1 to $9. For example, $1 retrieves the first argument passed to the script, $2 the second, and so on. Beyond the ninth parameter ($9), you cannot directly use $10 to refer to the tenth parameter as Bash interprets it as ${1}0 (i.e., the first parameter followed by a literal '0').