FPART(1) | General Commands Manual | FPART(1) |
fpart
— Sort and
pack files into partitions
fpart |
[-h ] [-V ]
-n num |
-f files |
-s size
[-i infile]
[-a ] [-o
outfile] [-0 ]
[-e ] [-P ]
[-v ] [-l ]
[-b ] [-y
pattern] [-Y
pattern] [-x
pattern] [-X
pattern] [-z ]
[-zz ] [-zzz ]
[-Z ] [-d
depth] [-D ]
[-E ] [-L ]
[-S ] [-w
cmd] [-W
cmd] [-R
cmd] [-p
num] [-q
num] [-r
num] [FILE or DIR...] |
The fpart
utility helps you sort file
trees and pack them into bags (called "partitions").
-n
num, --parts
num-f
,
-s
or -L
.-f
files, --files
files-s
and -L
.-s
size, --size
size-f
and -L
. You can
use a human-friendly unit suffix here (k, m, g, t, p).-o
outfile-
”, 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).-0
-o
.-e
/
” to each directory
entry.-P
-zzz
to produce partitions that
can be synchronized
in parallel
whith tools such as cpio(1) or tar(1).
Adding parent directories at the end of each partition ensures that
modification times get reapplied to directories whatever the processing
order of partitions is. Directories added that way are 0-sized and
not
subject to partition counters (for example, a file limit given using
option -f
will be exceeded by n parent
directories). Also, they are not subject to inclusion/exclusion options (
-y
, -Y
,
-x
, -X
) and they always
have an ending “/
” even if option
-e
has not been used (this simplifies symlinks
handling as we always want to add targets here, never the links
themselves). That option may lead to creating duplicate directory entries
when next partition begins with a directory entry that has already been
added as a parent when closing the previous partition. Only intermediate
partitions will get parent directories added, not the very last one which
gets its parents through option -zzz
when
fts(3) crawling finishes. Requires live mode (option
-L
)-v
,
--verbose
-l
-b
-y
pattern, --include
pattern[
”,
“]
”,
“*
”,
“?
”) may be used. Include patterns
are ignored when computing size of directories.-Y
pattern-y
but case insensitive. This option may
not be available on your platform (at least
FreeBSD and GNU/Linux support it, Solaris does
not).-x
pattern, --exclude
pattern-y
and
-Y
. In this case, exclusion is performed after.
This option may be specified several times. Pattern
may be a leaf (file or directory) name or a specific path. Shell pattern
matching characters (“[
”,
“]
”,
“*
”,
“?
”) may be used. Exclude patterns
also apply when computing size of directories.-X
pattern-x
but case insensitive. This option may
not be available on your platform (at least
FreeBSD and GNU/Linux support it, Solaris does
not).-z
-d
or -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.-zz
-zzz
-Z
-L
)
and option -zz
( or
-zzz
)-d
depth-D
,
--leaf-dirs
-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.-E
,
--dirs-only
-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.-L
,
--live
-s
and -S
). As a
consequence, it will generate partitions slightly larger than the size
specified with option -s
. This option can be used
in conjunction with options -f
and
-s
, but not with option
-n
.-S
-s
) and print them to
stdout (even when using option -o
) as belonging
to a pseudo-partition S (as in 'S'kipped). It allows a consumer to handle
them immediately through a separate process (no fpart hook will be
executed for skipped files). That option can only be used in Live mode
(option -L
), when a maximum partition size has
been given (option -s
).-w
cmd, --pre-part-cmd
cmdFPART_HOOKTYPE
("pre-part",
"post-part" or "post-run"),
FPART_PARTFILENAME
(current partition's output
file name), FPART_PARTNUMBER
(current partition
number), FPART_PARTSIZE
(current partition's
size), FPART_TOTALSIZE
(total partitions' size),
FPART_PARTNUMFILES
(number of files packed in
current partition), FPART_TOTALNUMFILES
(total
number of files packed so far), FPART_PARTERRNO
(0
if every single partition's entry has been read without error, else last
erroneous entry's errno. For error detection to work properly, you may
need to rebuild fpart using embedded fts(3) library,
depending on the version shipped with your OS),
FPART_PID
(PID of fpart),
FPART_TOTALNUMPARTS
(total number of partitions
generated so far). Variables may or may not be defined, depending on
requested options and current partition's state when the hook is
triggered. 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 (i.e. use absolute paths within hooks). Size-related variables
are affected by preloading, overloading and rounding options.-W
cmd, --post-part-cmd
cmd-w
, but executes cmd
when finishing a partition (after having closed last output file, if
any).-R
cmd, --post-run-cmd
cmd-w
and -W
but
executes cmd just once before exiting. Note that
only FPART_TOTALSIZE and FPART_TOTALNUMFILES environment variables are
available in post-run hooks.-p
num-q
num-r
numHere are some examples:
fpart -n 3
-o var-parts /var
fpart
-s 4724464025 -o music-parts /path/to/music ./*.mp3
find /usr !
-type d | fpart -f 10000 -i - /home | grep '^1 '
du * | fpart -n 2
-a
Fpart has been written by Ganaël LAPLANCHE and is available under the BSD license on http://contribs.martymac.org
No bug known (yet).
November 18, 2011 | Debian |