• Advertisement
Sign in to follow this  

BASH Function

This topic is 3969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok say you have something like this
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"

Share this post


Link to post
Share on other sites
Advertisement
Use cut(1):


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]

Share this post


Link to post
Share on other sites
Oh, oops.

There wasn't supposed to be a '$' in front of 'variable'.

(I was hacking Perl at the time, so...)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement