1FPART(1) BSD General Commands Manual FPART(1)
2
4 fpart — Sort and pack files into partitions.
5
7 fpart [-h] [-V] -n num | -f files | -s size [-i infile] [-a] [-o outfile]
8 [-0] [-e] [-v] [-l] [-b] [-y pattern] [-Y pattern] [-x pattern]
9 [-X pattern] [-z] [-zz] [-zzz] [-d depth] [-D] [-E] [-L] [-w cmd]
10 [-W cmd] [-p num] [-q num] [-r num] [FILE or DIR...]
11
13 The fpart utility helps you sort file trees and pack them into bags
14 (called "partitions").
15
17 -h Print help
18
19 -V Print version
20
22 -n num Create exactly num partitions and try to generate partitions with
23 the same size and number of files. This option cannot be used in
24 conjunction with -f, -s or -L.
25
26 -f files
27 Create partitions containing at most files files or directories.
28 This option can be used in conjunction with -s and -L.
29
30 -s size
31 Create partitions with a maximum size of size bytes. With this
32 option, partition 0 may be used to handle files that do not fit
33 in a regular partition, given the provided size limit. This
34 option can be used in conjunction with -f and -L.
35
37 -i infile
38 Read file list from infile. If infile is “-”, then list is read
39 from stdin.
40
41 -a Input contains arbitrary values; just sort them (do not crawl
42 filesystem). Input must follow the “size(blank)path” scheme.
43 This option is incompatible with crawling-related options.
44
46 -o outfile
47 Output partitions' contents to outfile template. Multiple files
48 will be generated given that template. Each outfile will get par‐
49 tition number as a suffix. If outfile is “-”, then partitions
50 will be printed to stdout, with partition number used as a prefix
51 (so you can grep partitions you are interested in, or do whatever
52 you want).
53
54 -0 End filenames with a null (’\0’) character when using option -o.
55
56 -e When adding directories (see DIRECTORY HANDLING ), add an ending
57 “/” to each directory entry.
58
59 -v Verbose mode (may be specified more than once).
60
62 -l Follow symbolic links (default: do not follow).
63
64 -b Do not cross filesystem boundaries (default: cross).
65
66 -y pattern
67 Include files or directories matching pattern only (and discard
68 all other files). This option may be specified several times. It
69 does not apply when computing size of directories to be added as
70 leaf entries (the computed size will then include every file
71 within directory).
72
73 -Y pattern
74 Same as -y but case insensitive. This option may not be available
75 on your platform (at least FreeBSD and GNU/Linux support it,
76 Solaris does not).
77
78 -x pattern
79 Exclude files or directories matching pattern. This option can
80 be used in conjunction with -y and -Y. In this case, exclusion
81 is performed after. This option may be specified several times.
82 It does not apply when computing size of directories to be added
83 as leaf entries (the computed size will then include every file
84 within directory).
85
86 -X pattern
87 Same as -x but case insensitive. This option may not be available
88 on your platform (at least FreeBSD and GNU/Linux support it,
89 Solaris does not).
90
92 -z Pack empty directories. By default, fpart will pack files only
93 (except when using the -d or -D options). This option can be use‐
94 ful for tools such as rsync(1) to be able to recreate a full file
95 tree when used with fpart (e.g. using rsync's --files-from
96 option). See the -zz option to also pack un-readable directories.
97
98 -zz Treat un-readable directories as empty, causing them to be packed
99 anyway.
100
101 -zzz Pack all directories (as empty). Useful when 3rd party tools need
102 directory entries to update them (e.g. cpio).
103
104 -d depth
105 After a certain depth, pack directories instead of files (direc‐
106 tories themselves will be added to partitions, instead of their
107 content). You can force a specific file to be packed anyway by
108 listing it on the command line explicitly.
109
110 -D Implies -z. Pack leaf directories: if a directory contains files
111 only, it will be packed as a single entry. You can force a spe‐
112 cific file to be packed anyway by listing it on the command line
113 explicitly.
114
115 -E Implies -D. Pack directories only (work on a per-directory
116 basis): in that mode, no file will be packed. Instead, each
117 directory will be packed as a single entry with a size being the
118 sum of all top-level files' sizes. You can force a specific file
119 to be packed anyway by listing it on the command line explicitly.
120
122 -L Live mode (default: disabled). When using this mode, partitions
123 will be generated while crawling filesystem. This option saves
124 time and memory, but does not give partition 0 a special meaning
125 (see option -s ). As a consequence, it can generate partitions
126 larger than the size specified with option -s. This option can
127 be used in conjunction with options -f and -s, but not with
128 option -n.
129
130 -w cmd When using live mode, execute cmd when starting a new partition
131 (before having opened next output file, if any). cmd is run in a
132 specific environment that provides several variables describing
133 the state of the program: FPART_HOOKTYPE ("pre-part" or "post-
134 part"), FPART_PARTFILENAME (current partition's output file
135 name), FPART_PARTNUMBER (current partition number),
136 FPART_PARTSIZE (current partition size), FPART_PARTNUMFILES (num‐
137 ber of files in current partition), FPART_PID (PID of fpart).
138 Note that variables may or may not be defined, depending of
139 requested options and current partition's state when the hook is
140 triggered. Also, note that hooks are executed in a synchronous
141 way while crawling filesystem, so 1) avoid executing commands
142 that take a long time to return as it slows down filesystem
143 crawling and 2) do not presume cwd (PWD) is the one fpart has
144 been started in, as it is regularly changed to speed up crawling
145 (use abolute paths within hooks).
146
147 -W cmd Same as -w, but executes cmd when finishing a partition (after
148 having closed last output file, if any).
149
151 -p num Preload each partition with num bytes.
152
153 -q num Overload each file size with num bytes.
154
155 -r num Round each file size up to next num bytes multiple. This option
156 can be used in conjunction with overloading, which is done
157 *before* rounding.
158
160 Here are some examples:
161
162 fpart -n 3 -o var-parts /var
163 Produce 3 partitions, with (hopefully) the same size and number
164 of files. Three files: var-parts.0, var-parts.1 and var-parts.2
165 are generated as output.
166
167 fpart -s 4724464025 -o music-parts /path/to/music ./*.mp3
168 Produce partitions of 4.4 GB, containing music files from
169 /path/to/music as well as MP3 files from current directory; with
170 such a partition size, each partition content will be ready to be
171 burnt to a DVD. Files music-parts.0 to music-parts.n, are gener‐
172 ated as output.
173
174 find /usr ! -type d | fpart -f 10000 -i - /home | grep '^0:'
175 Produce partitions containing 10000 files each by examining /usr
176 first and then /home and display only partition 0 on stdout.
177
178 du * | fpart -n 2 -a
179 Produce two partitions by using du(1) output. Fpart will not
180 examine the file system but instead use arbitrary values printed
181 by du(1) and sort them.
182
184 du(1), find(1), fpsync(1), grep(1), rsync(1)
185
187 Fpart has been written by Ganaël LAPLANCHE and is available under the BSD
188 license on
189 http://contribs.martymac.org
190
192 No bug known (yet).
193
194BSD November 18, 2011 BSD