File: files-to-excludes

package info (click to toggle)
rsync 3.2.3-4%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,452 kB
  • sloc: ansic: 42,298; sh: 5,934; perl: 933; python: 825; asm: 665; makefile: 349; cpp: 289; awk: 191
file content (27 lines) | stat: -rwxr-xr-x 534 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl
# This script takes an input of filenames and outputs a set of
# include/exclude directives that can be used by rsync to copy
# just the indicated files using an --exclude-from=FILE option.
use strict;

my %hash;

while (<>) {
    chomp;
    s#^/+##;
    my $path = '/';
    while (m#([^/]+/)/*#g) {
	$path .= $1;
	print "+ $path\n" unless $hash{$path}++;
    }
    if (m#([^/]+)$#) {
	print "+ $path$1\n";
    } else {
	delete $hash{$path};
    }
}

foreach (sort keys %hash) {
    print "- $_*\n";
}
print "- /*\n";