1FPART(1)                  BSD General Commands Manual                 FPART(1)
2

NAME

4     fpart — Sort and pack files into partitions
5

SYNOPSIS

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

DESCRIPTION

13     The fpart utility helps you sort file trees and pack them into bags
14     (called "partitions").
15

GENERAL OPTIONS

17     -h      Print help
18
19     -V      Print version
20

PARTITION CONTROL

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 op‐
34             tion can be used in conjunction with -f and -L.  You can use a
35             human-friendly unit suffix here (k, m, g, t, p).
36

INPUT CONTROL

38     -i infile
39             Read file list from infile.  If infile is “-”, then list is read
40             from stdin.
41
42     -a      Input contains arbitrary values; just sort them (do not crawl
43             filesystem).  Input must follow the “size(blank)path” scheme.
44             This option is incompatible with crawling-related options.
45

OUTPUT CONTROL

47     -o outfile
48             Output partitions' contents to outfile template.  Multiple files
49             will be generated given that template.  Each outfile will get
50             partition number as a suffix.  If outfile is “-”, then partitions
51             will be printed to stdout, with partition number used as a prefix
52             (so you can grep partitions you are interested in, or do whatever
53             you want).
54
55     -0      End filenames with a null (’\0’) character when using option -o.
56
57     -e      When adding directories (see DIRECTORY HANDLING ), add an ending
58             “/” to each directory entry.
59
60     -v      Verbose mode (may be specified more than once).
61

FILESYSTEM CRAWLING CONTROL

63     -l      Follow symbolic links (default: do not follow).
64
65     -b      Do not cross filesystem boundaries (default: cross).
66
67     -y pattern
68             Include files or directories matching pattern only (and discard
69             all other files).  This option may be specified several times.
70             Pattern may be a leaf (file or directory) name or a specific
71             path.  Shell pattern matching characters (“[”, “]”, “*”, “?”) may
72             be used.  Include patterns are ignored when computing size of di‐
73             rectories.
74
75     -Y pattern
76             Same as -y but case insensitive.  This option may not be avail‐
77             able on your platform (at least FreeBSD and GNU/Linux support it,
78             Solaris does not).
79
80     -x pattern
81             Exclude files or directories matching pattern.  This option can
82             be used in conjunction with -y and -Y.  In this case, exclusion
83             is performed after.  This option may be specified several times.
84             Pattern may be a leaf (file or directory) name or a specific
85             path.  Shell pattern matching characters (“[”, “]”, “*”, “?”) may
86             be used.  Exclude patterns also apply when computing size of di‐
87             rectories.
88
89     -X pattern
90             Same as -x but case insensitive.  This option may not be avail‐
91             able on your platform (at least FreeBSD and GNU/Linux support it,
92             Solaris does not).
93

DIRECTORY HANDLING

95     -z      Pack empty directories.  By default, fpart will pack files only
96             (except when using the -d or -D options).  This option can be
97             useful for tools such as rsync(1) to be able to recreate a full
98             file tree when used with fpart (e.g. using rsync's --files-from
99             option).  See the -zz option to also pack un-readable directo‐
100             ries.
101
102     -zz     Treat un-readable directories as empty, causing them to be packed
103             anyway.
104
105     -zzz    Pack all directories (as empty).  Useful when 3rd party tools
106             need directory entries to update them (e.g. cpio or tar).
107
108     -d depth
109             After a certain depth, pack directories instead of files (direc‐
110             tories themselves will be added to partitions, instead of their
111             content).  You can force a specific file to be packed anyway by
112             listing it on the command line explicitly.
113
114     -D      Implies -z.  Pack leaf directories: if a directory contains files
115             only, it will be packed as a single entry.  You can force a spe‐
116             cific file to be packed anyway by listing it on the command line
117             explicitly.
118
119     -E      Implies -D.  Pack directories only (work on a per-directory ba‐
120             sis): in that mode, no file will be packed.  Instead, each direc‐
121             tory will be packed as a single entry with a size being the sum
122             of all top-level files' sizes.  You can force a specific file to
123             be packed anyway by listing it on the command line explicitly.
124

LIVE MODE

126     -L      Live mode (default: disabled).  When using this mode, partitions
127             will be generated while crawling filesystem.  This option saves
128             time and memory, but does not give partition 0 a special meaning
129             (see option -s ).  As a consequence, it can generate partitions
130             larger than the size specified with option -s.  This option can
131             be used in conjunction with options -f and -s, but not with op‐
132             tion -n.
133
134     -w cmd  When using live mode, execute cmd when starting a new partition
135             (before having opened next output file, if any).  cmd is run in a
136             specific environment that provides several variables describing
137             the state of the program: FPART_HOOKTYPE ("pre-part" or "post-
138             part"), FPART_PARTFILENAME (current partition's output file
139             name), FPART_PARTNUMBER (current partition number),
140             FPART_PARTSIZE (current partition size), FPART_PARTNUMFILES (num‐
141             ber of files in current partition), FPART_PID (PID of fpart).
142             Note that variables may or may not be defined, depending of re‐
143             quested options and current partition's state when the hook is
144             triggered.  Also, note that hooks are executed in a synchronous
145             way while crawling filesystem, so 1) avoid executing commands
146             that take a long time to return as it slows down filesystem
147             crawling and 2) do not presume cwd (PWD) is the one fpart has
148             been started in, as it is regularly changed to speed up crawling
149             (use absolute paths within hooks).
150
151     -W cmd  Same as -w, but executes cmd when finishing a partition (after
152             having closed last output file, if any).
153

SIZE HANDLING

155     -p num  Preload each partition with num bytes.  You can use a human-
156             friendly unit suffix here (k, m, g, t, p).
157
158     -q num  Overload each file size with num bytes.  You can use a human-
159             friendly unit suffix here (k, m, g, t, p).
160
161     -r num  Round each file size up to next num bytes multiple.  This option
162             can be used in conjunction with overloading, which is done *be‐
163             fore* rounding.  You can use a human-friendly unit suffix here
164             (k, m, g, t, p).
165

EXAMPLES

167     Here are some examples:
168
169     fpart -n 3 -o var-parts /var
170             Produce 3 partitions, with (hopefully) the same size and number
171             of files.  Three files: var-parts.0, var-parts.1 and var-parts.2
172             are generated as output.
173
174     fpart -s 4724464025 -o music-parts /path/to/music ./*.mp3
175             Produce partitions of 4.4 GB, containing music files from
176             /path/to/music as well as MP3 files from current directory; with
177             such a partition size, each partition content will be ready to be
178             burnt to a DVD.  Files music-parts.0 to music-parts.n, are gener‐
179             ated as output.
180
181     find /usr ! -type d | fpart -f 10000 -i - /home | grep '^0:'
182             Produce partitions containing 10000 files each by examining /usr
183             first and then /home and display only partition 0 on stdout.
184
185     du * | fpart -n 2 -a
186             Produce two partitions by using du(1) output.  Fpart will not ex‐
187             amine the file system but instead use arbitrary values printed by
188             du(1) and sort them.
189

SEE ALSO

191     du(1), find(1), fpsync(1), grep(1), rsync(1)
192

AUTHOR, AVAILABILITY

194     Fpart has been written by Ganaël LAPLANCHE and is available under the BSD
195     license on http://contribs.martymac.org
196

BUGS

198     No bug known (yet).
199
200BSD                            November 18, 2011                           BSD
Impressum