.TH "HXCOPY" "1" "9 Dec 2008" "7.x" "HTML-XML-utils"
.SH NAME
hxcopy \- copy an HTML file and update its relative links
.SH SYNOPSIS
.B hxcopy
.RB "[\| " \-i
.IR old-URL " \|]"
.RB "[\| " \-o
.IR new-URL " \|]"
.RB "[\| " \-s " \|]"
.RB "[\| " \-v " \|]"
.RI "[\| " file-or-URL " [\| " file-or-URL " \|] \|]"
.SH DESCRIPTION
The
.B hxcopy
command copies its first argument to its second argument, while
updating relative links. The input is assumed to be HTML or XHTML and
may be slightly reformatted in the process.
.PP
If the second argument is omitted,
.B hxcopy
writes to standard output. In this case the option
.B \-o
is required. If the first argument is also omitted,
.B hxcopy
reads from standard input. In this case the option
.B \-i
is required.
.SH OPTIONS
The following options are supported:
.TP 10
.BI \-i " old-URL"
For the purposes of updating relative links, act as if
.I old-URL
is the location from which the input is copied. If this option is
omitted, the actual location of the first argument is used for
calculating relative links.
.TP
.BI \-o " new-URL"
For the purposed of updating relative links, act as if
.I new-URL
is the location to which the input is copied. If this option is
omitted, the actual location of the second argument is used for
calculating relative links.
.TP
.B \-s
Also replace links to self. This effects the treatment of empty URLs,
i.e., links to the document itself that do not explicitly name the
document. Without
.BR \-s ","
implicit links to the document itself (href=""), to a fragment of the
document itself (href="#foo") or to a query over the document itself
(href="?query") are not changed and will thus refer to (a fragment of)
the new document. With
.BR \-s ","
these links are rewritten to refer to (a fragment of) the old document
instead.
.TP
.B \-v
Print the version number and exit immediately.
.SH ENVIRONMENT
To use a proxy to retrieve remote files, set the environment variables
.B http_proxy
and
.BR ftp_proxy "."
E.g.,
.B http_proxy="http://localhost:8080/"
.SH BUGS
Unlike the last argument of
.BR cp (1),
the last argument of
.B hxcopy
must be a file, not a directory.
.PP
The second argument must be a local file. Writing to a URL is not yet
implemented. To work around this, replace
.B "hxcopy file.html http://example.org/file.html"
by
.B "hxcopy -o http://example.org/file.html file.html tmp.html"
and then upload tmp.html to the given URL with some other command,
such as
.BR curl (1).
The first argument, however, may be a URL.
.B hxcopy
will download the given file. (Currently only HTTP is supported.)
.SH EXAMPLE
Assume the HTML file foo.html contains a relative link to
"../bar.html". Here are some examples of commands:
.TP
.B "hxcopy foo.html bar/foo.html"
The file foo.html is copied to ../bar/foo.html and the relative link
to "../bar.html" becomes "../../bar.html".
.TP
.B "hxcopy foo.html ../foo.html"
The file foo.html is copied to ../foo.html and the relative link to
"../bar.html" is rewritten as "bar.html".
.TP
.B "hxcopy -i http://my.org/dir1/foo.html -o http://my.org/foo.html file1.html file2.html"
The file file1.html is copied to file2.html and the relative link to
"../bar.html" is rewritten as "bar.html". A command like this may
be useful to update files that are later uploaded to a server.
.SH "SEE ALSO"
.BR cp (1),
.BR curl (1),
.BR hxwls (1)