[ Level 2 ] Get last argument in bash.
You could use the following methods to get the last argument that you pass to script.
Wish this helps.
regards,
Stanley Huang
#!/bin/bash getLastArg1() { for last do true done echo $last } getLastArg2() { echo $@ | awk '{print($NF)}' } getLastArg3() { eval echo `echo \\$${#@}` } getLastArg1 $@ getLastArg2 $@ getLastArg3 $@
$ ./test.sh a b c c c c $
Wish this helps.
regards,
Stanley Huang
Comments
Post a Comment