Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #275374
| From | Karl Vogel <vogelke@pobox.com> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: Shell function & variable usage. |
| Date | 2024-12-07 12:40 +0100 |
| Message-ID | <JR1kd-epAe-3@gated-at.bofh.it> (permalink) |
| References | <JQQ5r-eiDW-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri 06 Dec 2024 at 18:30:27 (-0500), peter@easthope.ca wrote:
> Hypothetical shell usages (1) & (2).
>
> (1)
> Restore() { \
> source=somewhere/Backup/ ;
> destination=elsewhere/workingDirectory ;
> rsync \
> --exclude '*.mp3' \
> --exclude '*.mp4' \
> -anuv $source $destination ; }
If you want to modify exclusions, you have to edit the code.
> (2)
> exclusions='*.mp3'
> exclusions+='*.mp4'
> Restore() { \
> source=somewhere/Backup/ ;
> destination=elsewhere/workingDirectory ;
> rsync \
> -anuv --exclude=$exclusions $source $destination ; }
I would put
*.mp[34]
in a separate config file. I usually name those after the script to
make them easier to find:
#!/usr/bin/env bash
export PATH=/usr/local/bin:/bin:/usr/bin
tag=${0##*/}
...
excfile="/usr/local/etc/${tag}-exclude"
test -s "$excfile" || { echo die screaming; exit 1; }
...
rsync -anuv --exclude-from="$excfile" "$source" "$destination"
--
Karl Vogel I don't speak for anyone but myself
COMMENT: That's an amazing deal, would snap it up if I had the money.
REPLY: You can eat next month. --Reddit on buying storage, 21 Nov 2024
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