In Bash, how do you access command line arguments inside a function?
Posted
by DonGar
on Stack Overflow
See other posts from Stack Overflow
or by DonGar
Published on 2010-04-29T21:31:04Z
Indexed on
2010/04/29
21:47 UTC
Read the original article
Hit count: 198
bash
I'm attempting to write a function in bash that will access the scripts command line arguments, but they are replaced with the positional arguments to the function. Is there any way for the function to access the command line arguments if they aren't passed in explicitly?
# Demo function
function stuff {
echo $0 $*
}
# Echo's the name of the script, but no command line arguments
stuff
# Echo's everything I want, but trying to avoid
stuff $*
© Stack Overflow or respective owner