fpart man page
fpart — Sort and pack files into partitions.
The fpart utility helps you sort file trees and pack them into bags (called "partitions").
Create exactly num partitions and try to generate partitions with the same size and number of files. This option cannot be used in conjunction with
Create partitions containing at most files files or directories. This option can be used in conjunction with
Create partitions with a maximum size of size bytes. With this option, partition 0 may be used to handle files that do not fit in a regular partition, given the provided size limit. This option can be used in conjunction with
Read file list from infile. If infile is “
-”, then list is read from stdin.
Input contains arbitrary values; just sort them (do not crawl filesystem). Input must follow the “
size(blank)path” scheme. This option is incompatible with crawling-related options.
Output partitions' contents to outfile template. Multiple files will be generated given that template. Each outfile will get partition number as a suffix. If outfile is “
-”, then partitions will be printed to stdout, with partition number used as a prefix (so you can grep partitions you are interested in, or do whatever you want).
End filenames with a null (’\0’) character when using option
When adding directories (see Directory Handling ), add an ending “
/” to each directory entry.
Verbose mode (may be specified more than once).
Filesystem Crawling Control
Follow symbolic links (default: do not follow).
Do not cross filesystem boundaries (default: cross).
Include files or directories matching pattern only (and discard all other files). This option may be specified several times. It does not apply when computing size of directories to be added as leaf entries (the computed size will then include every file within directory).
-ybut case insensitive. This option may not be available on your platform (at least FreeBSD and GNU/Linux support it, Solaris does not).
Exclude files or directories matching pattern. This option can be used in conjunction with
-Y. In this case, exclusion is performed after. This option may be specified several times. It does not apply when computing size of directories to be added as leaf entries (the computed size will then include every file within directory).
-xbut case insensitive. This option may not be available on your platform (at least FreeBSD and GNU/Linux support it, Solaris does not).
Pack empty directories. By default, fpart will pack files only (except when using the
-dor -D options). This option can be useful for tools such as rsync(1) to be able to recreate a full file tree when used with fpart (e.g. using rsync's --files-from option). See the -zz option to also pack un-readable directories.
Treat un-readable directories as empty, causing them to be packed anyway.
Pack all directories (as empty). Useful when 3rd party tools need directory entries to update them (e.g. cpio).
After a certain depth, pack directories instead of files (directories themselves will be added to partitions, instead of their content). You can force a specific file to be packed anyway by listing it on the command line explicitly.
Implies -z. Pack leaf directories: if a directory contains files only, it will be packed as a single entry. You can force a specific file to be packed anyway by listing it on the command line explicitly.
Implies -D. Pack directories only (work on a per-directory basis): in that mode, no file will be packed. Instead, each directory will be packed as a single entry with a size being the sum of all top-level files' sizes. You can force a specific file to be packed anyway by listing it on the command line explicitly.
Live mode (default: disabled). When using this mode, partitions will be generated while crawling filesystem. This option saves time and memory, but does not give partition 0 a special meaning (see option
-s). As a consequence, it can generate partitions larger than the size specified with option
-s. This option can be used in conjunction with options
-s, but not with option
When using live mode, execute cmd when starting a new partition (before having opened next output file, if any). cmd is run in a specific environment that provides several variables describing the state of the program:
FPART_HOOKTYPE("pre-part" or "post-part"),
FPART_PARTFILENAME(current partition's output file name),
FPART_PARTNUMBER(current partition number),
FPART_PARTSIZE(current partition size),
FPART_PARTNUMFILES(number of files in current partition),
FPART_PID(PID of fpart). Note that variables may or may not be defined, depending of requested options and current partition's state when the hook is triggered. Also, note that hooks are executed in a synchronous way while crawling filesystem, so 1) avoid executing commands that take a long time to return as it slows down filesystem crawling and 2) do not presume cwd (PWD) is the one fpart has been started in, as it is regularly changed to speed up crawling (use abolute paths within hooks).
-w, but executes cmd when finishing a partition (after having closed last output file, if any).
Preload each partition with num bytes.
Overload each file size with num bytes.
Round each file size up to next num bytes multiple. This option can be used in conjunction with overloading, which is done *before* rounding.
Here are some examples:
fpart -n 3 -o var-parts /var
Produce 3 partitions, with (hopefully) the same size and number of files. Three files: var-parts.0, var-parts.1 and var-parts.2 are generated as output.
fpart -s 4724464025 -o music-parts /path/to/music ./*.mp3
Produce partitions of 4.4 GB, containing music files from /path/to/music as well as MP3 files from current directory; with such a partition size, each partition content will be ready to be burnt to a DVD. Files music-parts.0 to music-parts.n, are generated as output.
find /usr ! -type d | fpart -f 10000 -i - /home | grep '^0:'
Produce partitions containing 10000 files each by examining /usr first and then /home and display only partition 0 on stdout.
du * | fpart -n 2 -a
Produce two partitions by using du(1) output. Fpart will not examine the file system but instead use arbitrary values printed by du(1) and sort them.
du(1), find(1), fpsync(1), grep(1), rsync(1)
Fpart has been written by Ganaël LAPLANCHE and is available under the BSD license on http://contribs.martymac.org
No bug known (yet).