What is the difference between $argv[1]
and $1
?
$argv[1]
and $argv[$1]
, which is correct?
I tried the below codes and obtained the outputs as mentioned below:
1)
#!/bin/bash
echo "The user $1 is logged on to the system on"
Run as: bash logs.sh home
Output: The user home is logged on to the system on
2)
#!/bin/bash
echo "The user $argv[1] is logged on to the system on"
Run as: bash logs.sh home
Output: The user [1] is logged on to the system on
3)
#!/bin/bash
echo "The user $argv[$1] is logged on to the system on"
Run as: bash logs.sh home
Output: The user [home] is logged on to the system on
Please clarify these.