ccp
can copy stdin or file to stdout, file to file, or files to directory, including recursive copying of directories.
While copying, it can apply one or several recodings.
A recoding maps each byte to one or several (e.g., zero) bytes.
Recoding tables are read from files.
A recoding table can be in the text form or in the binary form.
You can easily write a recoding table as a text file.
Binary files are usually smaller and can be loaded faster.
They can be produced from text recoding files by ccp
.
ccp
can also multiply recodings - produce a table which has
the same effect as several recodings applied sequentially.
This multiplication is, of course, not commutative.
The base distribution contains recoding tables for converting
DOS text files to Unix text files and back (d2u and u2d),
conversions between russian encodings
koi8-r, alt (cp866), win (cp1251), iso-8859-5, LaTeX (T2A) in any direction
(k2a
, i2k
, a2w
, k2l
, etc.),
for converting these encodings to transliteration
(recodings k2t
, etc.),
and for filtering out control characters (recoding c
).
Some typical examples of use:
ccp -d2u /dos/mydir/*.txt somedir/
converts DOS text files to UNIX text files
ccp -d2u -a2k /dos/mydir/rus.txt rus.txt
converts DOS russian text in alt to UNIX russian text in koi8
ccp -u2d -k2w rus.txt /dos/mydir/rus.txt
converts UNIX russian text in koi8 to Windows russian text
ccp -d2u -a2k =da2uk
produces the table for recoding DOS alt -> UNIX koi8
ccp -da2uk /dos/mydir/rus.txt | more
copies rus.txt to stdout using this table
ccp -x2y file1 dir2 file3 dir
copies file1
, dir2
(recursively),
and file3
into dir
ccp -x2y dir/ newname
creates the directory newname
,
and copies all files in dir
into it (recursively)
ccp +a2k =k2a
inverts a2k producing k2a
ccp -l2k -k2w =
dumps the product of the recodings l2k
and k2a
into stdout, in the text form
foo | ccp -i2k | bar
copies stdin to stdout (use in pipes)
ccp -x2y - | telnet must.die | ccp -y2x -
telnet to a host using a different encoding
ccp -c strange_file | more
view file filtering out control characters
You can easily write your own recoding tables. Here is an example:
# This is a comment 'a' -> 'b' 0F -> 0A # hexadecimal 'x' -> 'uvw' 'y' -> # y is recoded to nothing 1A -> 2A2B2C # hexadecimal "z" -> "abc" # "z" and 'z' are equivalent "'" -> '"' # ' is recoded to "If you call this file
code.16
you can use
ccp -code foo barYou can also compile the text file
code.16
into a binary form code
:
ccp -code =codeSeveral options may be combined:
ccp -code1 -code2 =code12 +code3 foo barmeans take recoding
code1
, multiply it by code2
,
store the result in code12
, then multiply by the recoding
inverse to code3
and copy foo to bar using the resulting
recoding.
You can specify a list of directories where to search for recoding tables
via the environment variable CCPPATH
.
They are separated by :.
By default, /usr/share/ccp:.
is used.
In each directory, ccp
first tries to find the binary form;
if not successful, then the text form with the extension .16
Download: ccp-1.2.tar.gz (11K), ccp-1.2-1.i686.rpm (18K), ccp-1.2-1.src.rpm (13K) (rpms are for Red Hat Enterprise Linux 4).