From: Greg Wooledge <g...@wooledge.org>
    Date: Sat, 7 Dec 2024 11:08:54 -0500
>     "${exclusions[@]//#/--exclude=}"

In a shell script; correct?

I'm making a shell function declared in .bashrc.  Numerous syntactical 
variations were unsuccessful.  Maybe a simple escape syntax is needed.

Stretched a test out to this.  it works.

Test() { \
  exclusions=( \
  'file' \
  '*.mp3' \
  '*.mp4' );
  echo "exclusions = ${exclusions[@]}";
  n=${#exclusions[@]};
  i=0;
  while [ "$i" -lt "$n" ]; do
    echo ${exclusions[$i]};
    exclusions[$i]="--exclude=${exclusions[$i]}";
    ((i++));
  done;
  echo "i = $i";
  echo "exclusions = ${exclusions[@]}";
}

When I'm happy with Test, will incorporate into the Backup function.

Thanks for the help,                      ... P.

-- 
VoIP:   +1 604 670 0140
work: https://en.wikibooks.org/wiki/User:PeterEasthope

Reply via email to