Get the nth positional argument in bash?
Positional argument can be obtained in bash by creating the following file
#!/bin/bash
#!/bin/bash
n=2
echo ${!n}
Running that file in the following way:
./file.sh sun mon tue wed
will print mon
The next one also gives the same result
eval echo \${$n}
Comments
Post a Comment