Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > S

shar(1)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

shar — make a shell archive package

SYNOPSIS

shar [options] [file|dir] ... > package

DESCRIPTION

The shar command bundles the named files and directories into a single distribution package suitable for mailing or moving. The files can contain any data, including executables. The resulting package, written to standard output, is a shell script file that can be edited (to add messages at the beginning, etc.).

To unpack package, use the sh command with the package name as an argument as follows:

sh package

When unpacking, the files and directories in package are written to the path names recorded in the archive.

If a directory is specified and the -d option is not given, all files beneath that directory are archived.

If a special file is specified, the appropriate mknod commands are emitted to recreate the file (see mknod(1M)).

shar protects the contained files from mail processing, if necessary, by inserting an @ character at the beginning of each line. If the file contains unusual data, the data is transformed into uuencode format, and a uudecode script is included in package so that the package can still be unpacked correctly by sh. See WARNINGS for more information about mailers and file modifications.

Access modes are preserved for both directories and files.

Options

shar recognizes the following options:

-a

Assume that files can be shipped, regardless of their contents; do not protect them specially. shar is conservative, and might decide to uuencode a file containing special characters (such as Ctrl-G) that the user knows do not need protection.

-A

Suppress warning messages regarding optional access control list entries. shar does not archive optional access control list entries in a file's access control list (see acl(5)). Normally, a warning message is printed for each file having optional access control list entries.

-b

Archive files under their base names, regardless of the original path names specified. The contents are thus unpacked into the current directory instead of to the originally specified path names. This allows you to archive files from many directories but unpack them into a single directory. It also allows you to unpack, for example, /usr/share/lib/termcap into ./termcap instead of overwriting the original one in /etc.

-c

Append to the package a simple data-integrity check using wc to ensure that the contents were not damaged in transit (see wc(1)). This check is performed automatically after unpacking. Also see WARNINGS below.

-C

Insert a line of the form --- cut here --- before the archive.

-d

If a directory is specified, do not transmit its contents, but rather only create the empty directory.

-Ddir

Cause the archive to contain code that notifies the user if his or her current directory is not the same as dir, which must be an absolute path. If the user is not in dir, the unpacking can be continued by responding yes to the archive's question.

-e

Cause the archive to contain code that prevents shar from unpacking files that would overwrite existing files.

-ffile

Read a list of file names from file and archive those files as if they were given as arguments.

-h

Follow symbolic links as if they were normal files or directories. If this option is not specified, shar archives the link.

-m

Retain modification and access times on files when they are unpacked.

-o

Preserve user and group ownership on files and directories.

-r

Cause the archive to contain code requiring that the user unpacking it be root. This is useful for processing system archives.

-s

Perform error checking using sum (see sum(1)). Both -c and -s can be specified for better error checking. Also see WARNINGS below.

-t

Write diagnostics and messages directly to your terminal instead of to the standard error. This is useful when invoking shar from programs (such as vi that normally combine standard error with standard output. Specifying -t also invokes the -v (verbose) option.

-u

Assume that the remote site has uudecode for unpacking. If this option is not specified, a version of uudecode is sent and compiled if any non-ASCII files are archived.

-v

Announce archived file names as they are packed. The -t option determines the destination for these announcements.

-Z

Compress files using compress (see compress(1)).

Most options are flagged in the header of the resulting package, thereby recording the format of the archive. The name of the archiver, system, and time/date of the archive are also recorded in the header.

EXAMPLES

To archive all files under your home directory, type:

cd; shar -cmos .

or

shar -cmos $HOME

To preserve your /dev directory, type:

shar -mor /dev >save_dev_files

To send your newest programs in directory newstuff in your home directory to a friend, type:

cd; shar -cmos newstuff | mailx -s 'new source' friend

RETURN VALUE

shar returns zero if successful; nonzero if problems with arguments occur.

DIAGNOSTICS

If the -b option is specified, shar refuses to archive directories.

WARNINGS

The modification and access time restoration does not take time zones into account.

Files with newline characters in their names scramble the table of contents.

Non-ASCII files with white space in their names do not unpack.

If a mailer such as elm(1) is used to transfer package to another system and the mailer is configured to expand tabs (by default or otherwise), any file in the archive will be modified if it contains tabs. If the -c or -s option is used to create the archive, the data-integrity check will fail during unpacking of any files in package that contain tab characters that were converted to spaces. (Some mailers that expand tabs when transferring files over a network may or may not expand tabs when transferring files to the sender or other users on the local system.) If an editor is used to modify any of the files in package, the data-integrity check will also fail for the files that were changed.

AUTHOR

shar was invented in the public domain. This version of shar was developed by HP.

FILES

/dev/tty

$TMPDIR/unpack*

For unpacking non-ASCII files if TMPDIR environment variable is set and the directory specified in it is accessible.

/var/tmp/unpack*

For unpacking non-ASCII files if TMPDIR environment variable is not set or the directory specified in it is not accessible and /var/tmp directory is accessible.

/tmp/unpack*

For unpacking non-ASCII files if TMPDIR environment variable is not set or the directory specified in it is not accessible and /var/tmp directory is not accessible.

$TMPDIR/compress*

For uncompressing files, which are packed using -Z option, if TMPDIR environment variable is set and the directory specified in it is accessible.

/var/tmp/compress*

For uncompressing files, which are packed using -Z option, if TMPDIR environment variable is not set or the directory specified in it is not accessible and /var/tmp directory is accessible.

/tmp/compress*

For uncompressing files, which are packed using -Z option, if TMPDIR environment variable is not set or the directory specified in it is not accessible and /var/tmp directory is not accessible.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.