tags:

views:

28

answers:

2

Working on an rsync script and the portion below is in a for loop. What I want to achieve is assign a variable to every arguement after 3. Just confused if I need to create another loop for that or not:

#1: name
  name=$1

  #2: ip 
  ip=$2

  #3: user
  user=$3

  #4+: folder exlusion
  #any lines higher than 3 will be created as exlcude folders
  ex[ARG_NUMBER]=
A: 

There might be a cleaner way, but something like this should work:

function foo() { 
  name=$1
  ip=$2
  user=$3
  rest=${@:4}
  echo "User " $user
  echo "Rest " $rest
}
Stephen
Thank you, the help is much appreciated :-)
+1  A: 

Make an array like this:

ex=("${@:4}")
Ignacio Vazquez-Abrams