Shar
shar is a self-extracting archive format for Unix-type systems. It encodes a group of files in a text-based format embedded in a shell script which may be executed directly from the command line in order to re-create the files that were archived.
There are many variant forms of shar archives, and there is no simple algorithm to extract files from all of them. Theoretically, it could require the full power of a Unix shell program, and the availability of every common Unix utility program. Variance in the environment that was used to create the shar file can result in receiving mixed results when it is to be extracted under a different environment, e.g. a shar file created under *BSD may produce warnings about touch
syntax not supported under Linux, if the shar file contains lines containing touch -am ...
, or legacy timestamp format, MODYYYRHHMM
, where MO
represents month, DY
represents day, YR
represents year, HH
represents the hour in 24 hour format, and MM
represents minutes, in numerical format, and year being the last two digits, e.g. 81
would make it 1981
.
Security warning: The usual ways of extracting from shar archives involve executing arbitrary code contained in the shar file. It is wiser to extract shar files inside a virtualized environment, with the appropriate guest operating system, e.g. FreeBSD.
Contents[hide] |
Examples
To extract the files in a shar archive:
$ sh example.shar
Another way to extract files. This also handles shar files that begin with email headers or other extraneous data.
$ unshar example.shar
Software
- shar files can be executed using a Unix Bourne-compatible shell (
sh
), and standard Unix utilities (particularlysed
). - GNU sharutils
- ppt/unshar: A perl script that tries to safely extract from shar files
- SharUtils for Windows
Sample files
- http://ftp.gnu.org/gnu/tar/ → *.shar*
- http://cd.textfiles.com/carousel344/MACTOSH/UNIX/ → *.SHA
- dexvert samples — archive/shar
References
- Wikipedia article
- Linux man pages: shar, unshar