Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #275360
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: Shell function & variable usage. |
| Date | 2024-12-07 00:50 +0100 |
| Message-ID | <JQQf7-eiHL-1@gated-at.bofh.it> (permalink) |
| References | <JQQ5r-eiDW-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri, Dec 06, 2024 at 15:11:51 -0700, peter@easthope.ca wrote:
> (2)
> exclusions='*.mp3'
> exclusions+='*.mp4'
> Restore() { \
> source=somewhere/Backup/ ;
> echo "source is $source." ;
> destination=elsewhere/workingDirectory ;
> echo "destination is $destination." ;
> rsync \
> -anuv --exclude=$exclusions $source $destination ; }
>
> In a realistic case, there are more than two exclusion patterns.
Store the exclusions in an ARRAY, not in a string. Then create a
second array which contains the spelled-out --exclude=... options.
#!/bin/bash
exclusions=( '*.mp3' '*.mp4' '*.wav' )
exclude=( "${exclusions[@]/#/--exclude=}" )
source=...
destination=...
rsync -anuv "${exclude[@]}" "$source" "$destination"
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Shell function & variable usage. peter@easthope.ca - 2024-12-07 00:40 +0100
Re: Shell function & variable usage. Greg Wooledge <greg@wooledge.org> - 2024-12-07 00:50 +0100
Re: Shell function & variable usage. peter@easthope.ca - 2024-12-07 15:40 +0100
Re: Shell function & variable usage. Greg Wooledge <greg@wooledge.org> - 2024-12-07 17:10 +0100
Re: Shell function & variable usage. peter@easthope.ca - 2024-12-08 19:50 +0100
Re: Shell function & variable usage. eben@gmx.us - 2024-12-07 00:50 +0100
Re: Shell function & variable usage. eben@gmx.us - 2024-12-07 01:00 +0100
Re: Shell function & variable usage. Greg Wooledge <greg@wooledge.org> - 2024-12-07 01:00 +0100
Re: Shell function & variable usage. Karl Vogel <vogelke@pobox.com> - 2024-12-07 12:40 +0100
Re: Shell function & variable usage. Anssi Saari <anssi.saari@debian-user.mail.kapsi.fi> - 2024-12-11 14:30 +0100
csiph-web