From: barmar@think.com (Barry Margolin)
Newsgroups: comp.unix.programmer
Subject: Re: I need help with shell archives
Date: 23 Jul 92 20:13:11 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
NNTP-Posting-Host: telecaster.think.com

In article <9207231705.AA09904@ha10.eng.ua.edu> skarkada@HA10.ENG.UA.EDU (Sudarshan Karkada) writes:
>	1)  How to create shell archives?
>        2)  What does 'shar' do?

2 is the answer to 1.  Here's a man page for shar (there are many different
implementations, so the precise options may differ for yours).

.TH SHAR 1 HEWLETT-PACKARD
.ad b
.SH NAME
shar \- make a shell archive package
.SH SYNOPSIS
\fBshar\fR [\fB-b\fR] [\fB-c\fR] [\fB-t\fR] [\fB-v\fR] \fIfiles...\fR
.SH DESCRIPTION
.I Shar
bundles the named
.IR file ( s )
into a single distribution package suitable for mailing or carrying around.
The files should be themselves mailable, e.g. not object code.
.IR Shar 's
resulting package, written to standard output, is an editable ASCII file.
It is actually a shell script which uses \fIsh\fR\^(1) "here" documents to
extract its contents into appropriate places.
.PP
The package is unwrapped by running \fIsh\fR\^(1) with the package name as an
argument.
Its files are written to the pathnames recorded in the archive.
.PP
Available options are:
.TP
.B \-b
Archive files under their basenames, regardless of the original pathnames
specified.
The contents are thus unpacked into the current directory instead of to the
originally-specified pathnames.
This allows you to archive files from many directories but unpack them into a
single directory.
It also allows you to unpack, say,
.I /etc/termcap
into
.I ./termcap
instead of overwriting the original one in
.IR /etc .
.TP
.B \-c
Cause
.I shar
to append to the package a simple data-integrity check using
.I wc
to insure that the contents were not damaged in transit.
This check is performed automatically after unpacking.
.TP
.B \-t
Write diagnostics and messages directly to
.IR /dev/tty ,
your terminal, instead of to standard error.
This is useful when invoking
.I shar
from programs such as
.I vi
which normally combine standard error with standard output.
Specifying 
.B \-t
also turns on the
.B \-v
(verbose) option.
.TP
.B \-v
Announce archived file names as they are packed.
The
.B \-t
option affects where these announcements go.
.SH FILES
/dev/tty    	if specified by the \fB-t\fR option
.br
/tmp/shar*  	used for the insurance check after unpacking
.br
cat, echo   	as subprocesses
.br
basename, wc	as optional subprocesses
.SH DIAGNOSTICS
.I Shar
refuses to archive nonexistent files and directories.
It terminates and does no archiving if it encounters them.
.PP
Exit status 1 is returned upon interrupt or trouble with arguments.
.SH "SEE ALSO"
ar(1),
basename(1),
cat(1),
cpio(1),
echo(1),
sh(1),
tar(1),
wc(1).
.SH BUGS
Ownerships and permissions for archived files are not retained.
.PP
The integrity check is very simple-minded.
In particular, it only notices if the number of characters, words, or lines is
altered.
It fails to catch bits flipped during transmission.
.PP
There should be a way to archive directories by name instead of using arguments
such as
.IR dir/* .
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
Newsgroups: comp.unix.programmer,comp.unix.questions,gnu.misc.discuss,gnu.gcc.help,comp.unix.ultrix