Skip to content

SHAR File Format (.shar)

A SHAR file is a POSIX shell script that, when executed, recreates the files it was built from by writing their contents out with shell commands like cat and echo.

.sharArchives

SHAR at a glance#

Full nameShell archive
File extension.shar
CategoryArchives
DeveloperJames Gosling
First released1982
MIME typesapplication/x-shar
CompressionUncompressed
FileFlip supportFileFlip does not handle this format

What a .shar file can hold#

These are the things a SHAR file either supports or does not, and they are what decides whether a conversion keeps everything or quietly drops something.

Human readableYes

Strengths and limitations of SHAR#

What SHAR does well

  • Needs nothing but a standard POSIX shell to unpack, no separate archive tool required
  • Plain text end to end, so it survived the line-ending and encoding mangling that old mail and Usenet gateways inflicted on binary attachments
  • A person can read exactly what a shar script will do before running it, which is more than can be said for many binary installers

Where SHAR falls short

  • Running one executes arbitrary shell commands with your full permissions, so an untrusted shar file is exactly as dangerous as an untrusted shell script
  • No standard compression, so a shar of anything but small text files is far larger than a tarball
  • Long superseded by tar and uuencode or base64 attachments for every use case it originally served

Shar mostly turns up now in old Usenet source archives or as an example of shell scripting; a new archive should almost never be built this way.

Convert a SHAR file to tar as soon as its files are extracted, since nothing about the shell-script format is worth keeping once the archive has been unpacked.

How to open a .shar file#

A .shar file opens in the programs below, grouped by the platform you are on.

PlatformPrograms that open it
macOSsh (POSIX shell)
Linuxsh (POSIX shell), GNU Sharutils (unshar)
WebFileFlip

SHAR questions people ask#

Is it safe to run a shar file?

Not unless you trust its source completely. A SHAR file is a plain shell script, so running it executes whatever commands were written into it with your own permissions, unlike extracting a ZIP or tar, which just writes files.

How do I extract a shar file without running it as a script?

Reading a SHAR file in a text editor first shows exactly what it will do, since it is plain shell commands, and the unshar tool from GNU Sharutils parses those out and creates the files without you having to execute the whole script yourself.

Why did anyone distribute software as a shell script?

Shar existed because early Usenet and email gateways handled plain text reliably but mangled binary attachments, so wrapping source code in a shell script that reconstructed the files on the other end was the practical way to send it before uuencode and MIME attachments became common.

Converting SHAR files#

FileFlip cannot open a .shar file, so there is nothing to convert it into here. It appears on the site as something other formats can be converted to.

FileFlip does not write .shar files, so nothing on the site converts into this format. It works as a source only.

Every conversion runs inside your browser. The file is read from your disk, the work happens on your own machine, and nothing is uploaded. How FileFlip works names the engine behind each family and how to verify that for yourself.