function function_A()
{
variable=$2
}
function_A "Hello World This is a Test"
the thing is what if you want variable to equal "World This is a Test"
how would you do that?
variable=$2 sets variable equal to "World"
BASH Function
ok say you have something like this
Use cut(1):
This should be in "Everything Unix".
[Edited by - sgm on June 13, 2007 6:26:23 PM]
function function_A() {variable=$(echo $1 | cut -f2- -d' ' -)}
This should be in "Everything Unix".
[Edited by - sgm on June 13, 2007 6:26:23 PM]
I think you can use $*
It captures all the arguments to a bash script, might do the same for functions...
It captures all the arguments to a bash script, might do the same for functions...
Oh, oops.
There wasn't supposed to be a '$' in front of 'variable'.
(I was hacking Perl at the time, so...)
There wasn't supposed to be a '$' in front of 'variable'.
(I was hacking Perl at the time, so...)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement