World Library  
Flag as Inappropriate
Email this Article




Filename extension .shar
Type of format Archive format, shell script

In the Unix operating system, shar (an abbreviation of shell archive) is an archive format. A shar file is a shell script, and executing it will recreate the files. This is a type of self-extracting archive file. It can be created with the Unix shar utility. To extract the files, only the standard Unix Bourne shell sh is usually required.

Note that shar is not specified by the Single Unix Specification, so it is not formally a component of Unix, but a legacy utility.


  • Details 1
  • Similar formats 2
  • See also 3
  • References 4
  • External links 5


While the shar format has the advantage of being plain text, it poses a risk due to being executable;[1][2] for this reason the older and more general tar file format is usually preferred even for transferring text files. GNU provides its own version of shar in the GNU Sharutils collection.

unshar programs have been written for other operating systems but are not always reliable; shar files are shell scripts and can theoretically do anything that a shell script can do (including using incompatible features of enhanced or workalike shells), limiting their utility outside the Unix world.

The drawback of self-extracting shell scripts (any kind, not just shar) is that they rely on a particular implementation of programs; shell archives created with older versions of makeself,[3] for example the original Unreal Tournament for Linux installer, fails to run on bash 3.x due to a change in how missing arguments to trap built-in command are handled.

Similar formats

In 1987, Michael Bednarek from The Melbourne Institute of Applied Economic and Social Research at the University of Melbourne developed a script for a similar purpose in the DIGITAL Command Language for the VMS operating system under the name "VMS_Shar version 2".[4]

The main purpose of this script was to allow the distribution of formatted program code through e-mail and Usenet newsgroups because:

  1. Mail transfer agents and NNTP server software only allowed printable ASCII characters (32–126);
  2. They tended to strip leading and trailing blanks and TAB characters;
  3. And they usually broke lines longer than 80 characters. VMS_SHAR protected leading blanks, and it split long files into parts of less than 16,000 bytes.

Version 4 introduced the protection of trailing blanks using the TPU text editor which then became the main engine of the script. Version 5 protected control characters like TAB, ESC, BEL. In 1988, beginning with version 6, the script was then extended by James A. Gray from Xerox.[5] Starting with version 7, Andy Harper from King's College London continued the development;.[6] The current version (as of 2008) is 8.5 (1994)[7]

See also


  1. ^ Apple (June 6, 1993). "Mac OS X shar(1) Man Page". Apple. Retrieved 2009-11-07. 
  2. ^ "Babylon Shar definition". Babylon Free Dictionary. Retrieved 2009-11-07. 
  3. ^ "makeself “trap” command fix". 2000-11-20. Retrieved 2011-08-30. 
  4. ^ Michael Bednarek (9 June 1987). "shar (sort of) for VMS".  
  5. ^ Jim Gray (8 May 1988). "VMS_SHARE V6.0".  
  6. ^ Andy Harper (6 July 1989). "VMS_SHARE version 7".  
  7. ^ Andy Harper (5 July 1995). "Announcing VMS_SHARE 8.5".  

External links

  •  – Linux User Commands Manual
  • Information about shar files (Carnegie Mellon)
  • GNU sharutils
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.