DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T s

⟦c1486e13d⟧ TextFile

    Length: 5375 (0x14ff)
    Types: TextFile
    Names: »slice.1«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec1/slice/slice.1« 

TextFile

.TH SLICE 1L "1986 December 11" "Cognos Inc."
.SH NAME
slice \- split a file into pieces, by pattern
.SH SYNOPSIS
.B slice
[ \fB\-f \fIfilename\fP ]
[ \fB\-i\fP\fIn\fP ]
[ \fB\-a\fP ]
[ \fB\-x\fP ]
[ \fB\-m\fP | \fB\-s\fP | \fB\-n\fP\fIn\fP ]
[ \fIformat\fP .\|.\|. ]
.LP
.sp
.B slice
[ \fB\-f \fIfilename\fP ]
[ \fB\-i\fP\fIn\fP ]
[ \fB\-a\fP ]
[ \fB\-x\fP ]
\fB\-e \fIexpression\fP 
[ \fIformat\fP .\|.\|. ]
.LP
.sp
.B slice
[ \fB\-f \fIfilename\fP ]
[ \fB\-i\fP\fIn\fP ]
[ \fB\-a\fP ]
[ \fB\-x\fP ]
\fIexpression\fP
[ \fIformat\fP .\|.\|. ]
.SH DESCRIPTION
.I Slice
splits large files into smaller ones.  The output files are named
according to the \fIformat\fR strings provided.  The input file is split
whenever a pattern is matched or every \fIn\fR lines, depending on the
options selected.  The syntax is similar to \fIgrep\fR, except for the
\fB-f\fR option, which has a different meaning.
Because some of the options are mutually exclusive,
there are three forms of the command.
.LP
The options allowed for \fIslice\fR are:
.IP "\fB-f\fR \fIfilename\fR"
Input for \fIslice\fR is taken from the named file rather than \fIstdin\fR.
.IP \-\fBi\fP\fIn\fP
The starting number for numbering output files generated by formats
containing %d (see \fIformat\fR below).  The default starting number is
one.
.IP \fB-a\fR
Causes the file to be split after the line matching the pattern, rather
than before (as is normally the case).
.IP \fB-x\fR
Causes the matched line to be excluded from the output files.  Handy
form eliminating cut lines, etc.
.IP \fB-m\fR
Uses the pattern '^From ' to split the file.  This is convenient for breaking
up a mailbox file.
.IP \fB-s\fR
Uses the pattern '^#!\ */bin/sh' to split the file.  This is ideal for
breaking up mail or news article containing a Bourne shell script.
.IP \-\fBn\fIn\fR
Split the file every \fIn\fR lines.  In this case, no pattern matching 
is performed.  This is the behaviour of \fIsplit (1)\fR,
except that the default output filename format for
\fIslice\fR is different.
.IP "\fB-e\fR \fIexpression\fR"
Uses the pattern specified by \fIexpression\fR to split the file.
The matched line is put in the new output
file.  The pattern may contain newlines (which match themselves).  See
.I ed (1)
for details of the regular expressions.
.IP \fIformat\fR
All three forms of the command allow the specification of zero or more
\fIformat\fR strings as non-flag parameters.
The format strings are formed after the fashion of
.I printf 
formats and are used to generate output filenames.
You can provide as many as you like.  Every time a split is required,
the next format will be selected.  If \fIslice\fR runs out of
formats, a warning will be issued and the last file will contain the
remainder of the input file.
.IP
A %s in the string will be replaced by the input filename (less pathname).
If the input file is \fIstdin\fR, the name \fIslice:\fR will be used
as a default.
.IP
A %d in a format string will be used to generate a unique number.  
Once \fIslice\fR encounters a format containing %d, it will continue
using it until the input file is exhausted.
.IP
The %d is replaced with a number starting at one for the first file, and 
incremented by one for each split.  The \-\fBi\fP option can be used
to start at a different number.
The default format is
.sp
\ \ \ \ %s:%03d
.sp
which results in files having names like \fIfilename\fR:01, 
\fIfilename\fR:02, \fIfilename\fR:03 and so on.  
The default format was chosen because the resulting files are listed 
in numerical order by
.I ls
or by
.I echo *
which is sometimes useful.
.LP
The special format string '+' is used to designate that \fIstdout\fR is
to be used.  This is handy for piping one of the pieces to another
command.  Since \fIslice\fR appends to its output files, its possible
for the same filename to appear more than once as a format.
.LP
.SH EXAMPLES
Split up a mail folder into files slice:001, slice:002, etc.:
.sp
	slice -m <folder
.sp
Split a news article containing a shell script into article.hdr and
article.sh:
.sp
	slice -s -f article '%s.hdr' '%s.sh'
.sp
Split stdin at every line of dashes into the files 0, 1, 2, etc.:
.sp
	cat anyfile | slice -i0 '^--* *$' '%d'
.sp
Split a news article containing a shell script into its header portion
and script portion.  Pipe the latter to \fIsh\fR to unshar it:
.sp
	slice -s <article README + | sh
.sp
Pipe the middle portion of a file to sh, keeping the head and tail in a
file called README (exclude cut lines):
.sp
	slice -f myfile -x '^--* [Cc]ut ' README + README | sh
.sp
Keep the middle portion of a file, discarding the head and tail:
.sp
	slice -f myfile '^--* [Cc]ut ' /dev/null middle /dev/null
.sp
.SH BUGS
Watch out for filename expansion by the shell.  This could cause
\fIslice\fR to interpret the extra filenames as output formats causing
slices to be appended to existing files.
.SH DIAGNOSTICS
Mostly straight-forward.
``Internal Error'' indicates a bug in \fIslice\fR, and should be reported.
Exit staus 1 indicates an error parsing options \- for example, if an unknown
flag was ued.
Exit status 2 indicates a meaningless combination was detected and rejected
(this is rare in practice).
Exit status 3 indicates a run-time problem \- for example, if a file couldn't
be opened.
.SH "SEE ALSO"
.I ed (1),
.I mail (1),
.I ls (1),
.I split (1),
.I mailsplit (l),
.I printf (3).