Blame man-pages-posix-2013-a/man1p/dd.1p

Packit 7cfc04
'\" et
Packit 7cfc04
.TH DD "1P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
Packit 7cfc04
.SH PROLOG
Packit 7cfc04
This manual page is part of the POSIX Programmer's Manual.
Packit 7cfc04
The Linux implementation of this interface may differ (consult
Packit 7cfc04
the corresponding Linux manual page for details of Linux behavior),
Packit 7cfc04
or the interface may not be implemented on Linux.
Packit 7cfc04
Packit 7cfc04
.SH NAME
Packit 7cfc04
dd
Packit 7cfc04
\(em convert and copy a file
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.LP
Packit 7cfc04
.nf
Packit 7cfc04
dd \fB[\fIoperand\fR...\fB]\fR
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The
Packit 7cfc04
.IR dd
Packit 7cfc04
utility shall copy the specified input file to the specified output
Packit 7cfc04
file with possible conversions using specific input and output block
Packit 7cfc04
sizes. It shall read the input one block at a time, using the
Packit 7cfc04
specified input block size; it shall then process the block of data
Packit 7cfc04
actually returned, which could be smaller than the requested block
Packit 7cfc04
size. It shall apply any conversions that have been specified and write
Packit 7cfc04
the resulting data to the output in blocks of the specified output
Packit 7cfc04
block size. If the
Packit 7cfc04
.BR bs =\c
Packit 7cfc04
.IR expr
Packit 7cfc04
operand is specified and no conversions other than
Packit 7cfc04
.BR sync ,
Packit 7cfc04
.BR noerror ,
Packit 7cfc04
or
Packit 7cfc04
.BR notrunc
Packit 7cfc04
are requested, the data returned from each input block shall be written
Packit 7cfc04
as a separate output block; if the read returns less than a full block
Packit 7cfc04
and the
Packit 7cfc04
.BR sync
Packit 7cfc04
conversion is not specified, the resulting output block shall be the
Packit 7cfc04
same size as the input block. If the
Packit 7cfc04
.BR bs =\c
Packit 7cfc04
.IR expr
Packit 7cfc04
operand is not specified, or a conversion other than
Packit 7cfc04
.BR sync ,
Packit 7cfc04
.BR noerror ,
Packit 7cfc04
or
Packit 7cfc04
.BR notrunc
Packit 7cfc04
is requested, the input shall be processed and collected into
Packit 7cfc04
full-sized output blocks until the end of the input is reached.
Packit 7cfc04
.P
Packit 7cfc04
The processing order shall be as follows:
Packit 7cfc04
.IP " 1." 4
Packit 7cfc04
An input block is read.
Packit 7cfc04
.IP " 2." 4
Packit 7cfc04
If the input block is shorter than the specified input block size and
Packit 7cfc04
the
Packit 7cfc04
.BR sync
Packit 7cfc04
conversion is specified, null bytes shall be appended to the input data
Packit 7cfc04
up to the specified size. (If either
Packit 7cfc04
.BR block
Packit 7cfc04
or
Packit 7cfc04
.BR unblock
Packit 7cfc04
is also specified,
Packit 7cfc04
<space>
Packit 7cfc04
characters shall be appended instead of null bytes.) The remaining
Packit 7cfc04
conversions and output shall include the pad characters as if they had
Packit 7cfc04
been read from the input.
Packit 7cfc04
.IP " 3." 4
Packit 7cfc04
If the
Packit 7cfc04
.BR bs =\c
Packit 7cfc04
.IR expr
Packit 7cfc04
operand is specified and no conversion other than
Packit 7cfc04
.BR sync
Packit 7cfc04
or
Packit 7cfc04
.BR noerror
Packit 7cfc04
is requested, the resulting data shall be written to the output as a
Packit 7cfc04
single block, and the remaining steps are omitted.
Packit 7cfc04
.IP " 4." 4
Packit 7cfc04
If the
Packit 7cfc04
.BR swab
Packit 7cfc04
conversion is specified, each pair of input data bytes shall be
Packit 7cfc04
swapped. If there is an odd number of bytes in the input block, the
Packit 7cfc04
last byte in the input record shall not be swapped.
Packit 7cfc04
.IP " 5." 4
Packit 7cfc04
Any remaining conversions (\c
Packit 7cfc04
.BR block ,
Packit 7cfc04
.BR unblock ,
Packit 7cfc04
.BR lcase ,
Packit 7cfc04
and
Packit 7cfc04
.BR ucase )
Packit 7cfc04
shall be performed. These conversions shall operate on the input data
Packit 7cfc04
independently of the input blocking; an input or output fixed-length
Packit 7cfc04
record may span block boundaries.
Packit 7cfc04
.IP " 6." 4
Packit 7cfc04
The data resulting from input or conversion or both shall be aggregated
Packit 7cfc04
into output blocks of the specified size. After the end of input is
Packit 7cfc04
reached, any remaining output shall be written as a block without
Packit 7cfc04
padding if
Packit 7cfc04
.BR conv =\c
Packit 7cfc04
.BR sync
Packit 7cfc04
is not specified; thus, the final output block may be shorter than the
Packit 7cfc04
output block size.
Packit 7cfc04
.SH OPTIONS
Packit 7cfc04
None.
Packit 7cfc04
.SH OPERANDS
Packit 7cfc04
All of the operands shall be processed before any input is read.
Packit 7cfc04
The following operands shall be supported:
Packit 7cfc04
.IP "\fBif\fR=\fIfile\fR" 10
Packit 7cfc04
Specify the input pathname; the default is standard input.
Packit 7cfc04
.IP "\fBof\fR=\fIfile\fR" 10
Packit 7cfc04
Specify the output pathname; the default is standard output. If the
Packit 7cfc04
.BR seek =\c
Packit 7cfc04
.IR expr
Packit 7cfc04
conversion is not also specified, the output file shall be truncated
Packit 7cfc04
before the copy begins if an explicit
Packit 7cfc04
.BR of =\c
Packit 7cfc04
.IR file
Packit 7cfc04
operand is specified, unless
Packit 7cfc04
.BR conv =\c
Packit 7cfc04
.BR notrunc
Packit 7cfc04
is specified. If
Packit 7cfc04
.BR seek =\c
Packit 7cfc04
.IR expr
Packit 7cfc04
is specified, but
Packit 7cfc04
.BR conv =\c
Packit 7cfc04
.BR notrunc
Packit 7cfc04
is not, the effect of the copy shall be to preserve the blocks in the
Packit 7cfc04
output file over which
Packit 7cfc04
.IR dd
Packit 7cfc04
seeks, but no other portion of the output file shall be preserved. (If
Packit 7cfc04
the size of the seek plus the size of the input file is less than the
Packit 7cfc04
previous size of the output file, the output file shall be shortened by
Packit 7cfc04
the copy. If the input file is empty and either the size of the seek is
Packit 7cfc04
greater than the previous size of the output file or the output file
Packit 7cfc04
did not previously exist, the size of the output file shall be set to
Packit 7cfc04
the file offset after the seek.)
Packit 7cfc04
.IP "\fBibs\fR=\fIexpr\fR" 10
Packit 7cfc04
Specify the input block size, in bytes, by
Packit 7cfc04
.IR expr
Packit 7cfc04
(default is 512).
Packit 7cfc04
.IP "\fBobs\fR=\fIexpr\fR" 10
Packit 7cfc04
Specify the output block size, in bytes, by
Packit 7cfc04
.IR expr
Packit 7cfc04
(default is 512).
Packit 7cfc04
.IP "\fBbs\fR=\fIexpr\fR" 10
Packit 7cfc04
Set both input and output block sizes to
Packit 7cfc04
.IR expr
Packit 7cfc04
bytes, superseding
Packit 7cfc04
.BR ibs =
Packit 7cfc04
and
Packit 7cfc04
.BR obs =.
Packit 7cfc04
If no conversion other than
Packit 7cfc04
.BR sync ,
Packit 7cfc04
.BR noerror ,
Packit 7cfc04
and
Packit 7cfc04
.BR notrunc
Packit 7cfc04
is specified, each input block shall be copied to the output as a
Packit 7cfc04
single block without aggregating short blocks.
Packit 7cfc04
.IP "\fBcbs\fR=\fIexpr\fR" 10
Packit 7cfc04
Specify the conversion block size for
Packit 7cfc04
.BR block
Packit 7cfc04
and
Packit 7cfc04
.BR unblock
Packit 7cfc04
in bytes by
Packit 7cfc04
.IR expr
Packit 7cfc04
(default is zero). If
Packit 7cfc04
.BR cbs =
Packit 7cfc04
is omitted or given a value of zero, using
Packit 7cfc04
.BR block
Packit 7cfc04
or
Packit 7cfc04
.BR unblock
Packit 7cfc04
produces unspecified results.
Packit 7cfc04
.RS 10 
Packit 7cfc04
.P
Packit 7cfc04
The application shall ensure that this operand is also specified if the
Packit 7cfc04
.BR conv =
Packit 7cfc04
operand is specified with a value of
Packit 7cfc04
.BR ascii ,
Packit 7cfc04
.BR ebcdic ,
Packit 7cfc04
or
Packit 7cfc04
.BR ibm .
Packit 7cfc04
For a
Packit 7cfc04
.BR conv =
Packit 7cfc04
operand with an
Packit 7cfc04
.BR ascii
Packit 7cfc04
value, the input is handled as described for the
Packit 7cfc04
.BR unblock
Packit 7cfc04
value, except that characters are converted to ASCII before any
Packit 7cfc04
trailing
Packit 7cfc04
<space>
Packit 7cfc04
characters are deleted. For
Packit 7cfc04
.BR conv =
Packit 7cfc04
operands with
Packit 7cfc04
.BR ebcdic
Packit 7cfc04
or
Packit 7cfc04
.BR ibm
Packit 7cfc04
values, the input is handled as described for the
Packit 7cfc04
.BR block
Packit 7cfc04
value except that the characters are converted to EBCDIC or IBM EBCDIC,
Packit 7cfc04
respectively, after any trailing
Packit 7cfc04
<space>
Packit 7cfc04
characters are added.
Packit 7cfc04
.RE
Packit 7cfc04
.IP "\fBskip\fR=\fIn\fR" 10
Packit 7cfc04
Skip
Packit 7cfc04
.IR n
Packit 7cfc04
input blocks (using the specified input block size) before starting to
Packit 7cfc04
copy. On seekable files, the implementation shall read the blocks or
Packit 7cfc04
seek past them; on non-seekable files, the blocks shall be read and the
Packit 7cfc04
data shall be discarded.
Packit 7cfc04
.IP "\fBseek\fR=\fIn\fR" 10
Packit 7cfc04
Skip
Packit 7cfc04
.IR n
Packit 7cfc04
blocks (using the specified output block size) from the beginning of the
Packit 7cfc04
output file before copying. On non-seekable files, existing blocks
Packit 7cfc04
shall be read and space from the current end-of-file to the specified
Packit 7cfc04
offset, if any, filled with null bytes; on seekable files, the
Packit 7cfc04
implementation shall seek to the specified offset or read the blocks as
Packit 7cfc04
described for non-seekable files.
Packit 7cfc04
.IP "\fBcount\fR=\fIn\fR" 10
Packit 7cfc04
Copy only
Packit 7cfc04
.IR n
Packit 7cfc04
input blocks.
Packit 7cfc04
.IP "\fBconv\fR=\fIvalue\fB[\fR,\fIvalue\fR\ .\|.\|.\fB]\fR" 10
Packit 7cfc04
.br
Packit 7cfc04
Where
Packit 7cfc04
.IR value s
Packit 7cfc04
are
Packit 7cfc04
<comma>-separated
Packit 7cfc04
symbols from the following list:
Packit 7cfc04
.RS 10 
Packit 7cfc04
.IP "\fBascii\fR" 9
Packit 7cfc04
Convert EBCDIC to ASCII; see
Packit 7cfc04
.IR "Table 4-7, ASCII to EBCDIC Conversion".
Packit 7cfc04
.IP "\fBebcdic\fR" 9
Packit 7cfc04
Convert ASCII to EBCDIC; see
Packit 7cfc04
.IR "Table 4-7, ASCII to EBCDIC Conversion".
Packit 7cfc04
.IP "\fBibm\fR" 9
Packit 7cfc04
Convert ASCII to a different EBCDIC set; see
Packit 7cfc04
.IR "Table 4-8, ASCII to IBM EBCDIC Conversion".
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.BR ascii ,
Packit 7cfc04
.BR ebcdic ,
Packit 7cfc04
and
Packit 7cfc04
.BR ibm
Packit 7cfc04
values are mutually-exclusive.
Packit 7cfc04
.IP "\fBblock\fR" 9
Packit 7cfc04
Treat the input as a sequence of
Packit 7cfc04
<newline>-terminated
Packit 7cfc04
or end-of-file-terminated variable-length records independent of the
Packit 7cfc04
input block boundaries. Each record shall be converted to a record with
Packit 7cfc04
a fixed length specified by the conversion block size. Any
Packit 7cfc04
<newline>
Packit 7cfc04
shall be removed from the input line;
Packit 7cfc04
<space>
Packit 7cfc04
characters shall be appended to lines that are shorter than their
Packit 7cfc04
conversion block size to fill the block. Lines that are longer than
Packit 7cfc04
the conversion block size shall be truncated to the largest number of
Packit 7cfc04
characters that fit into that size; the number of truncated lines shall
Packit 7cfc04
be reported (see the STDERR section).
Packit 7cfc04
.RS 9 
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.BR block
Packit 7cfc04
and
Packit 7cfc04
.BR unblock
Packit 7cfc04
values are mutually-exclusive.
Packit 7cfc04
.RE
Packit 7cfc04
.IP "\fBunblock\fR" 9
Packit 7cfc04
Convert fixed-length records to variable length. Read a number of bytes
Packit 7cfc04
equal to the conversion block size (or the number of bytes remaining in
Packit 7cfc04
the input, if less than the conversion block size), delete all trailing
Packit 7cfc04
<space>
Packit 7cfc04
characters, and append a
Packit 7cfc04
<newline>.
Packit 7cfc04
.IP "\fBlcase\fR" 9
Packit 7cfc04
Map uppercase characters specified by the
Packit 7cfc04
.IR LC_CTYPE
Packit 7cfc04
keyword
Packit 7cfc04
.BR tolower
Packit 7cfc04
to the corresponding lowercase character. Characters for which no
Packit 7cfc04
mapping is specified shall not be modified by this conversion.
Packit 7cfc04
.RS 9 
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.BR lcase
Packit 7cfc04
and
Packit 7cfc04
.BR ucase
Packit 7cfc04
symbols are mutually-exclusive.
Packit 7cfc04
.RE
Packit 7cfc04
.IP "\fBucase\fR" 9
Packit 7cfc04
Map lowercase characters specified by the
Packit 7cfc04
.IR LC_CTYPE
Packit 7cfc04
keyword
Packit 7cfc04
.BR toupper
Packit 7cfc04
to the corresponding uppercase character. Characters for which no
Packit 7cfc04
mapping is specified shall not be modified by this conversion.
Packit 7cfc04
.IP "\fBswab\fR" 9
Packit 7cfc04
Swap every pair of input bytes.
Packit 7cfc04
.IP "\fBnoerror\fR" 9
Packit 7cfc04
Do not stop processing on an input error. When an input error occurs, a
Packit 7cfc04
diagnostic message shall be written on standard error, followed by the
Packit 7cfc04
current input and output block counts in the same format as used at
Packit 7cfc04
completion (see the STDERR section). If the
Packit 7cfc04
.BR sync
Packit 7cfc04
conversion is specified, the missing input shall be replaced with null
Packit 7cfc04
bytes and processed normally; otherwise, the input block shall be
Packit 7cfc04
omitted from the output.
Packit 7cfc04
.IP "\fBnotrunc\fR" 9
Packit 7cfc04
Do not truncate the output file. Preserve blocks in the output
Packit 7cfc04
file not explicitly written by this invocation of the
Packit 7cfc04
.IR dd
Packit 7cfc04
utility. (See also the preceding
Packit 7cfc04
.BR of =\c
Packit 7cfc04
.IR file
Packit 7cfc04
operand.)
Packit 7cfc04
.IP "\fBsync\fR" 9
Packit 7cfc04
Pad every input block to the size of the
Packit 7cfc04
.BR ibs =
Packit 7cfc04
buffer, appending null bytes. (If either
Packit 7cfc04
.BR block
Packit 7cfc04
or
Packit 7cfc04
.BR unblock
Packit 7cfc04
is also specified, append
Packit 7cfc04
<space>
Packit 7cfc04
characters, rather than null bytes.)
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
The behavior is unspecified if operands other than
Packit 7cfc04
.BR conv =
Packit 7cfc04
are specified more than once.
Packit 7cfc04
.P
Packit 7cfc04
For the
Packit 7cfc04
.BR bs =,
Packit 7cfc04
.BR cbs =,
Packit 7cfc04
.BR ibs =,
Packit 7cfc04
and
Packit 7cfc04
.BR obs =
Packit 7cfc04
operands, the application shall supply an expression specifying a size
Packit 7cfc04
in bytes. The expression,
Packit 7cfc04
.IR expr ,
Packit 7cfc04
can be:
Packit 7cfc04
.IP " 1." 4
Packit 7cfc04
A positive decimal number
Packit 7cfc04
.IP " 2." 4
Packit 7cfc04
A positive decimal number followed by
Packit 7cfc04
.IR k ,
Packit 7cfc04
specifying multiplication by 1\|024
Packit 7cfc04
.IP " 3." 4
Packit 7cfc04
A positive decimal number followed by
Packit 7cfc04
.IR b ,
Packit 7cfc04
specifying multiplication by 512
Packit 7cfc04
.IP " 4." 4
Packit 7cfc04
Two or more positive decimal numbers (with or without
Packit 7cfc04
.IR k
Packit 7cfc04
or
Packit 7cfc04
.IR b )
Packit 7cfc04
separated by
Packit 7cfc04
.IR x ,
Packit 7cfc04
specifying the product of the indicated values
Packit 7cfc04
.P
Packit 7cfc04
All of the operands are processed before any input is read.
Packit 7cfc04
.P
Packit 7cfc04
The following two tables display the octal number character values used
Packit 7cfc04
for the
Packit 7cfc04
.BR ascii
Packit 7cfc04
and
Packit 7cfc04
.BR ebcdic
Packit 7cfc04
conversions (first table) and for the
Packit 7cfc04
.BR ibm
Packit 7cfc04
conversion (second table). In both tables, the ASCII values are the row
Packit 7cfc04
and column headers and the EBCDIC values are found at their
Packit 7cfc04
intersections. For example, ASCII 0012 (LF) is the second row, third
Packit 7cfc04
column, yielding 0045 in EBCDIC. The inverted tables (for EBCDIC to
Packit 7cfc04
ASCII conversion) are not shown, but are in one-to-one correspondence
Packit 7cfc04
with these tables. The differences between the two tables are
Packit 7cfc04
highlighted by small boxes drawn around five entries.
Packit 7cfc04
.br
Packit 7cfc04
.sp
Packit 7cfc04
.ce 1
Packit 7cfc04
\fBTable 4-7: ASCII to EBCDIC Conversion\fR
Packit 7cfc04
.bp
Packit 7cfc04
.sp
Packit 7cfc04
.ce 1
Packit 7cfc04
\fBTable 4-8: ASCII to IBM EBCDIC Conversion\fR
Packit 7cfc04
.SH STDIN
Packit 7cfc04
If no
Packit 7cfc04
.BR if =
Packit 7cfc04
operand is specified, the standard input shall be used. See the INPUT
Packit 7cfc04
FILES section.
Packit 7cfc04
.SH "INPUT FILES"
Packit 7cfc04
The input file can be any file type.
Packit 7cfc04
.SH "ENVIRONMENT VARIABLES"
Packit 7cfc04
The following environment variables shall affect the execution of
Packit 7cfc04
.IR dd :
Packit 7cfc04
.IP "\fILANG\fP" 10
Packit 7cfc04
Provide a default value for the internationalization variables that are
Packit 7cfc04
unset or null. (See the Base Definitions volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "Section 8.2" ", " "Internationalization Variables"
Packit 7cfc04
for the precedence of internationalization variables used to determine
Packit 7cfc04
the values of locale categories.)
Packit 7cfc04
.IP "\fILC_ALL\fP" 10
Packit 7cfc04
If set to a non-empty string value, override the values of all the
Packit 7cfc04
other internationalization variables.
Packit 7cfc04
.IP "\fILC_CTYPE\fP" 10
Packit 7cfc04
Determine the locale for the interpretation of sequences of bytes of
Packit 7cfc04
text data as characters (for example, single-byte as opposed to
Packit 7cfc04
multi-byte characters in arguments and input files), the classification
Packit 7cfc04
of characters as uppercase or lowercase, and the mapping of characters
Packit 7cfc04
from one case to the other.
Packit 7cfc04
.IP "\fILC_MESSAGES\fP" 10
Packit 7cfc04
.br
Packit 7cfc04
Determine the locale that should be used to affect the format and
Packit 7cfc04
contents of diagnostic messages written to standard error and
Packit 7cfc04
informative messages written to standard output.
Packit 7cfc04
.IP "\fINLSPATH\fP" 10
Packit 7cfc04
Determine the location of message catalogs for the processing of
Packit 7cfc04
.IR LC_MESSAGES .
Packit 7cfc04
.SH "ASYNCHRONOUS EVENTS"
Packit 7cfc04
For SIGINT, the
Packit 7cfc04
.IR dd
Packit 7cfc04
utility shall interrupt its current processing, write status
Packit 7cfc04
information to standard error, and exit as though terminated by
Packit 7cfc04
SIGINT. It shall take the standard action for all other signals; see
Packit 7cfc04
the ASYNCHRONOUS EVENTS section in
Packit 7cfc04
.IR "Section 1.4" ", " "Utility Description Defaults".
Packit 7cfc04
.SH STDOUT
Packit 7cfc04
If no
Packit 7cfc04
.BR of =
Packit 7cfc04
operand is specified, the standard output shall be used. The nature of
Packit 7cfc04
the output depends on the operands selected.
Packit 7cfc04
.SH STDERR
Packit 7cfc04
On completion,
Packit 7cfc04
.IR dd
Packit 7cfc04
shall write the number of input and output blocks to standard error. In
Packit 7cfc04
the POSIX locale the following formats shall be used:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
"%u+%u records in\en", <\fInumber of whole input blocks\fR>,
Packit 7cfc04
    <\fInumber of partial input blocks\fR>
Packit 7cfc04
.P
Packit 7cfc04
"%u+%u records out\en", <\fInumber of whole output blocks\fR>,
Packit 7cfc04
    <\fInumber of partial output blocks\fR>
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
A partial input block is one for which
Packit 7cfc04
\fIread\fR()
Packit 7cfc04
returned less than the input block size. A partial output block is one
Packit 7cfc04
that was written with fewer bytes than specified by the output block
Packit 7cfc04
size.
Packit 7cfc04
.P
Packit 7cfc04
In addition, when there is at least one truncated block, the number of
Packit 7cfc04
truncated blocks shall be written to standard error. In the POSIX
Packit 7cfc04
locale, the format shall be:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
"%u truncated %s\en", <\fInumber of truncated blocks\fR>, "record" (if
Packit 7cfc04
    <\fInumber of truncated blocks\fR> is one) "records" (otherwise)
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
Diagnostic messages may also be written to standard error.
Packit 7cfc04
.SH "OUTPUT FILES"
Packit 7cfc04
If the
Packit 7cfc04
.BR of =
Packit 7cfc04
operand is used, the output shall be the same as described in the
Packit 7cfc04
STDOUT section.
Packit 7cfc04
.SH "EXTENDED DESCRIPTION"
Packit 7cfc04
None.
Packit 7cfc04
.SH "EXIT STATUS"
Packit 7cfc04
The following exit values shall be returned:
Packit 7cfc04
.IP "\00" 6
Packit 7cfc04
The input file was copied successfully.
Packit 7cfc04
.IP >0 6
Packit 7cfc04
An error occurred.
Packit 7cfc04
.SH "CONSEQUENCES OF ERRORS"
Packit 7cfc04
If an input error is detected and the
Packit 7cfc04
.BR noerror
Packit 7cfc04
conversion has not been specified, any partial output block shall be
Packit 7cfc04
written to the output file, a diagnostic message shall be written, and
Packit 7cfc04
the copy operation shall be discontinued. If some other error is
Packit 7cfc04
detected, a diagnostic message shall be written and the copy operation
Packit 7cfc04
shall be discontinued.
Packit 7cfc04
.LP
Packit 7cfc04
.IR "The following sections are informative."
Packit 7cfc04
.SH "APPLICATION USAGE"
Packit 7cfc04
The input and output block size can be specified to take advantage of
Packit 7cfc04
raw physical I/O.
Packit 7cfc04
.P
Packit 7cfc04
There are many different versions of the EBCDIC codesets. The ASCII and
Packit 7cfc04
EBCDIC conversions specified for the
Packit 7cfc04
.IR dd
Packit 7cfc04
utility perform conversions for the version specified by the tables.
Packit 7cfc04
.SH EXAMPLES
Packit 7cfc04
The following command:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
dd if=/dev/rmt0h  of=/dev/rmt1h
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
copies from tape drive 0 to tape drive 1, using a common historical
Packit 7cfc04
device naming convention.
Packit 7cfc04
.P
Packit 7cfc04
The following command:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
dd ibs=10  skip=1
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
strips the first 10 bytes from standard input.
Packit 7cfc04
.P
Packit 7cfc04
This example reads an EBCDIC tape blocked ten 80-byte EBCDIC card
Packit 7cfc04
images per block into the ASCII file
Packit 7cfc04
.BR x :
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
dd if=/dev/tape of=x ibs=800 cbs=80 conv=ascii,lcase
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.SH RATIONALE
Packit 7cfc04
The OPTIONS section is listed as ``None'' because there are no options
Packit 7cfc04
recognized by historical
Packit 7cfc04
.IR dd
Packit 7cfc04
utilities. Certainly, many of the operands could have been designed to
Packit 7cfc04
use the Utility Syntax Guidelines, which would have resulted in the
Packit 7cfc04
classic hyphenated option letters. In this version of this volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR dd
Packit 7cfc04
retains its curious JCL-like syntax due to the large number of
Packit 7cfc04
applications that depend on the historical implementation.
Packit 7cfc04
.P
Packit 7cfc04
A suggested implementation technique for
Packit 7cfc04
.BR conv =\c
Packit 7cfc04
.BR noerror ,\c
Packit 7cfc04
.BR sync
Packit 7cfc04
is to zero (or
Packit 7cfc04
<space>-fill,
Packit 7cfc04
if
Packit 7cfc04
.BR block ing
Packit 7cfc04
or
Packit 7cfc04
.BR unblock ing)
Packit 7cfc04
the input buffer before each read and to write the contents of the
Packit 7cfc04
input buffer to the output even after an error. In this manner, any
Packit 7cfc04
data transferred to the input buffer before the error was detected is
Packit 7cfc04
preserved. Another point is that a failed read on a regular file or a
Packit 7cfc04
disk generally does not increment the file offset, and
Packit 7cfc04
.IR dd
Packit 7cfc04
must then seek past the block on which the error occurred; otherwise,
Packit 7cfc04
the input error occurs repetitively. When the input is a magnetic tape,
Packit 7cfc04
however, the tape normally has passed the block containing the error
Packit 7cfc04
when the error is reported, and thus no seek is necessary.
Packit 7cfc04
.P
Packit 7cfc04
The default
Packit 7cfc04
.BR ibs =
Packit 7cfc04
and
Packit 7cfc04
.BR obs =
Packit 7cfc04
sizes are specified as 512 bytes because there are historical (largely
Packit 7cfc04
portable) scripts that assume these values. If they were left
Packit 7cfc04
unspecified, unusual results could occur if an implementation chose an
Packit 7cfc04
odd block size.
Packit 7cfc04
.P
Packit 7cfc04
Historical implementations of
Packit 7cfc04
.IR dd
Packit 7cfc04
used
Packit 7cfc04
\fIcreat\fR()
Packit 7cfc04
when processing
Packit 7cfc04
.BR of =\c
Packit 7cfc04
.IR file .
Packit 7cfc04
This makes the
Packit 7cfc04
.BR seek =
Packit 7cfc04
operand unusable except on special files. The
Packit 7cfc04
.BR conv =\c
Packit 7cfc04
.BR notrunc
Packit 7cfc04
feature was added because more recent BSD-based implementations use
Packit 7cfc04
\fIopen\fR()
Packit 7cfc04
(without O_TRUNC) instead of
Packit 7cfc04
\fIcreat\fR(),
Packit 7cfc04
but they fail to delete output file contents after the data copied.
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.IR w
Packit 7cfc04
multiplier (historically meaning
Packit 7cfc04
.IR word ),
Packit 7cfc04
is used in System V to mean 2 and in 4.2 BSD to mean 4. Since
Packit 7cfc04
.IR word
Packit 7cfc04
is inherently non-portable, its use is not supported by this volume of POSIX.1\(hy2008.
Packit 7cfc04
.P
Packit 7cfc04
Standard EBCDIC does not have the characters
Packit 7cfc04
.BR '[' 
Packit 7cfc04
and
Packit 7cfc04
.BR ']' .
Packit 7cfc04
The values used in the table are taken from a common print train that
Packit 7cfc04
does contain them. Other than those characters, the print train values
Packit 7cfc04
are not filled in, but appear to provide some of the motivation for the
Packit 7cfc04
historical choice of translations reflected here.
Packit 7cfc04
.P
Packit 7cfc04
The Standard EBCDIC table provides a 1:1 translation for all 256
Packit 7cfc04
bytes.
Packit 7cfc04
.P
Packit 7cfc04
The IBM EBCDIC table does not provide such a translation. The marked
Packit 7cfc04
cells in the tables differ in such a way that:
Packit 7cfc04
.IP " 1." 4
Packit 7cfc04
EBCDIC 0112 (\c
Packit 7cfc04
.BR '\(ct' )
Packit 7cfc04
and 0152 (broken pipe) do not appear in the table.
Packit 7cfc04
.IP " 2." 4
Packit 7cfc04
EBCDIC 0137 (\c
Packit 7cfc04
.BR '\(no' )
Packit 7cfc04
translates to/from ASCII 0236 (\c
Packit 7cfc04
.BR '^' ).
Packit 7cfc04
In the standard table, EBCDIC 0232 (no graphic) is used.
Packit 7cfc04
.IP " 3." 4
Packit 7cfc04
EBCDIC 0241 (\c
Packit 7cfc04
.BR '~' )
Packit 7cfc04
translates to/from ASCII 0176 (\c
Packit 7cfc04
.BR '~' ).
Packit 7cfc04
In the standard table, EBCDIC 0137 (\c
Packit 7cfc04
.BR '\(no' )
Packit 7cfc04
is used.
Packit 7cfc04
.IP " 4." 4
Packit 7cfc04
0255 (\c
Packit 7cfc04
.BR '[' )
Packit 7cfc04
and 0275 (\c
Packit 7cfc04
.BR ']' )
Packit 7cfc04
appear twice, once in the same place as for the standard table and once
Packit 7cfc04
in place of 0112 (\c
Packit 7cfc04
.BR '\(ct' )
Packit 7cfc04
and 0241 (\c
Packit 7cfc04
.BR '~' ).
Packit 7cfc04
.P
Packit 7cfc04
In net result:
Packit 7cfc04
.sp
Packit 7cfc04
.RS
Packit 7cfc04
EBCDIC 0275 (\c
Packit 7cfc04
.BR ']' )
Packit 7cfc04
displaced EBCDIC 0241 (\c
Packit 7cfc04
.BR '~' )
Packit 7cfc04
in cell 0345.
Packit 7cfc04
.P
Packit 7cfc04
\0\0\0\0That displaced EBCDIC 0137 (\c
Packit 7cfc04
.BR '\(no' )
Packit 7cfc04
in cell 0176.
Packit 7cfc04
.P
Packit 7cfc04
\0\0\0\0That displaced EBCDIC 0232 (no graphic) in cell 0136.
Packit 7cfc04
.P
Packit 7cfc04
\0\0\0\0That replaced EBCDIC 0152 (broken pipe) in cell 0313.
Packit 7cfc04
.P
Packit 7cfc04
EBCDIC 0255 (\c
Packit 7cfc04
.BR '[' )
Packit 7cfc04
replaced EBCDIC 0112 (\c
Packit 7cfc04
.BR '\(ct' ).
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
This translation, however, reflects historical practice that (ASCII)
Packit 7cfc04
.BR '~' 
Packit 7cfc04
and
Packit 7cfc04
.BR '\(no' 
Packit 7cfc04
were often mapped to each other, as were
Packit 7cfc04
.BR '[' 
Packit 7cfc04
and
Packit 7cfc04
.BR '\(ct' ;
Packit 7cfc04
and
Packit 7cfc04
.BR ']' 
Packit 7cfc04
and (EBCDIC)
Packit 7cfc04
.BR '~' .
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.BR cbs
Packit 7cfc04
operand is required if any of the
Packit 7cfc04
.BR ascii ,
Packit 7cfc04
.BR ebcdic ,
Packit 7cfc04
or
Packit 7cfc04
.BR ibm
Packit 7cfc04
operands are specified. For the
Packit 7cfc04
.BR ascii
Packit 7cfc04
operand, the input is handled as described for the
Packit 7cfc04
.BR unblock
Packit 7cfc04
operand except that characters are converted to ASCII before the
Packit 7cfc04
trailing
Packit 7cfc04
<space>
Packit 7cfc04
characters are deleted. For the
Packit 7cfc04
.BR ebcdic
Packit 7cfc04
and
Packit 7cfc04
.BR ibm
Packit 7cfc04
operands, the input is handled as described for the
Packit 7cfc04
.BR block
Packit 7cfc04
operand except that the characters are converted to EBCDIC or IBM
Packit 7cfc04
EBCDIC after the trailing
Packit 7cfc04
<space>
Packit 7cfc04
characters are added.
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.BR block
Packit 7cfc04
and
Packit 7cfc04
.BR unblock
Packit 7cfc04
keywords are from historical BSD practice.
Packit 7cfc04
.P
Packit 7cfc04
The consistent use of the word
Packit 7cfc04
.BR record
Packit 7cfc04
in standard error messages matches most historical practice. An
Packit 7cfc04
earlier version of System V used
Packit 7cfc04
.BR block ,
Packit 7cfc04
but this has been updated in more recent releases.
Packit 7cfc04
.P
Packit 7cfc04
Early proposals only allowed two numbers separated by
Packit 7cfc04
.BR x
Packit 7cfc04
to be used in a product when specifying
Packit 7cfc04
.BR bs =,
Packit 7cfc04
.BR cbs =,
Packit 7cfc04
.BR ibs =,
Packit 7cfc04
and
Packit 7cfc04
.BR obs =
Packit 7cfc04
sizes. This was changed to reflect the historical practice of allowing
Packit 7cfc04
multiple numbers in the product as provided by Version 7 and all
Packit 7cfc04
releases of System V and BSD.
Packit 7cfc04
.P
Packit 7cfc04
A change to the
Packit 7cfc04
.BR swab
Packit 7cfc04
conversion is required to match historical practice and is the result
Packit 7cfc04
of IEEE PASC Interpretations 1003.2 #03 and #04, submitted for the
Packit 7cfc04
ISO\ POSIX\(hy2:\|1993 standard.
Packit 7cfc04
.P
Packit 7cfc04
A change to the handling of SIGINT is required to match historical
Packit 7cfc04
practice and is the result of IEEE PASC Interpretation 1003.2 #06
Packit 7cfc04
submitted for the ISO\ POSIX\(hy2:\|1993 standard.
Packit 7cfc04
.SH "FUTURE DIRECTIONS"
Packit 7cfc04
None.
Packit 7cfc04
.SH "SEE ALSO"
Packit 7cfc04
.IR "Section 1.4" ", " "Utility Description Defaults",
Packit 7cfc04
.IR "\fIsed\fR\^",
Packit 7cfc04
.IR "\fItr\fR\^"
Packit 7cfc04
.P
Packit 7cfc04
The Base Definitions volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "Chapter 8" ", " "Environment Variables"
Packit 7cfc04
.SH COPYRIGHT
Packit 7cfc04
Portions of this text are reprinted and reproduced in electronic form
Packit 7cfc04
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
Packit 7cfc04
-- Portable Operating System Interface (POSIX), The Open Group Base
Packit 7cfc04
Specifications Issue 7, Copyright (C) 2013 by the Institute of
Packit 7cfc04
Electrical and Electronics Engineers, Inc and The Open Group.
Packit 7cfc04
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
Packit 7cfc04
event of any discrepancy between this version and the original IEEE and
Packit 7cfc04
The Open Group Standard, the original IEEE and The Open Group Standard
Packit 7cfc04
is the referee document. The original Standard can be obtained online at
Packit 7cfc04
http://www.unix.org/online.html .
Packit 7cfc04
Packit 7cfc04
Any typographical or formatting errors that appear
Packit 7cfc04
in this page are most likely
Packit 7cfc04
to have been introduced during the conversion of the source files to
Packit 7cfc04
man page format. To report such errors, see
Packit 7cfc04
https://www.kernel.org/doc/man-pages/reporting_bugs.html .