shar

The shar (shell archive) utilities are for creating archives of text files. There are a lot of uses for them, but here I will show how to use them to archive projects, and e-mail them. Shar sends in 7 bit mode, so it is safe in e-mail unlike tar and zip.

creating archive files

If you have some files you can give them as arguements to 'shar' and this will store them in the archive, which is just output to stdout. To capture this output you can redirect or pipe the output. You will see some output on the screen that will let you know what files were stored in the archive, the reason you see this output is that it went to stderr and was not redirected with the actual archive contents.

Example 1 : mail prog.cpp prog.h and Makefile to apollo account xx000 ( note: this will e-mail the archive without creating an archive file ).

shar prog.cpp prog.h Makefile | mail xx000
Example 2 : store prog.cpp prog.h and Makefile in an archive named foo.sh ( note: this doesn't e-mail the archive it just creates the archive file ).
shar prog.cpp prog.h Makefile > foo.sh

extracting archive files

The archive files are actually just a shell script. This means you can just run them and they will extract. If the file already exists, it will not overwrite it ( a message will say the file is being being skipped ). Example : extract the files from the archive named foo.sh
sh foo.sh