How to make a .shar file?

shar is not installed by default and it is part of shar-utils. To install:

sudo apt-get install sharutils

The man page for shar has a good amount of information, warnings and examples. From the link:

Description

Shar creates "shell archives" (or shar files) which are in text format and can be mailed. These files may be unpacked later by executing them with /bin/sh. The resulting archive is sent to standard out unless the -o option is given. A wide range of features provide extensive flexibility in manufacturing shars and in specifying shar "smartness". Archives may be "vanilla" or comprehensive.

and it has some examples:

Examples

shar *.c > cprog.shar          # all C prog sources
shar -Q *.[ch] > cprog.shar    # non-verbose, .c and .h files
shar -B -l28 -oarc.sh *.arc    # all binary .arc files, into
                               # files arc.sh.01 thru arc.sh.NN
shar -f /lcl/src/u*.c > u.sh   # use only the filenames

Have a look though all the options at the man page for compression, integrity checks, internationalization and more.


It has a counterpart called unshar

Description

Unshar scans mail messages looking for the start of a shell archive. It then passes the archive through a copy of the shell to unpack it. It will accept multiple files. If no files are given, standard input is used.

To extract the files in a shar archive:

$ sh example.shar

unshar is another way to extract files. This also handles .shar files that begin with email headers or other extraneous data.

$ unshar example.shar

You need to install sharutils

sudo apt-get install sharutils

Once installed, you can refer to its man file to know how to use it.

man shar

Basic syntax is:

shar <list of files>