ArticleslgStudy

science

Shar (file format)

Shar (file format) is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Shar (file format) rather than just read about it. In short: In the Unix operating system, shar (from "shell archive") is an archive format created with the Unix shar utility. A shar file is a type of self-extracting archive, because it is a valid shell script, and executing it will recreate the files.

Key takeaways

  • Shar (file format) belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Shar (file format) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Shar (file format) from memory before moving on to harder problems.

Reference excerpt

In the Unix operating system, shar (from "shell archive") is an archive format created with the Unix shar utility. A shar file is a type of self-extracting archive, because it is a valid shell script, and executing it will recreate the files. To extract the files, only the standard Unix Bourne shell sh is usually required. shar files are also sometimes called "sharchives" (from "/bin/sh archive"). Note that the shar command is not specified by the Single UNIX Specification, so it is not formally a component of Unix, but a legacy utility.

Details The shar format was developed before the advent of the MIME standard as a way to email one or more files, any of which could be text or binary. At the time, there was no portable way to reliably email a non-text file or a collection of files, e.g., a tar file format archive. Shar was also a common format for distributing software via Usenet, e.g., comp.sources.unix. Today, MIME is the preferred method for emailing files as the shar format poses a risk due to being executable;. For legacy reasons, GNU provides its own version of shar in the GNU Sharutils collection.

History and variants James Gosling is credited with writing the first version of the shar utility in 1982, and also wrote an early example (allegedly 1978–79) of the concept in the form of this simple shell script:

The following variants of shar are known:

shar 1.x (1982) by Gosling. Public domain shell script. Current FreeBSD shar. 3-clause BSD license, shell script. Adds md5sum. shar2 or xshar (1988) by William Davidsen. Public domain, C program. shar3 (1989) by Warren Tucker. shar 3.49 (1990) by Richard H. Gumpertz. Adds uuencode support. Current GNU sharutils. GPLv3, C program. cshar (1984) by Michael A. Thompson and Mark Smith, now lost to bitrot. C program. cshar (1988) by Rich Salz, C program. Likely influenced shar 3.49. ccshar (1996), a modification to output a csh script instead. Rarely used on Usenet. GNU shar is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.

Similar formats A version of the same concept, but for the VMS operating system, was written in 1987 by Michael Bednarek from the Melbourne Institute of Applied Economic and Social Research as a DCL script, VMS_SHAR.COM. This was later maintained and extended by James A. Gray from Xerox, and Andy Harper from King's College London. makeself (2001–) is a shell script that generates self-extracting tarballs (*.run, application/x-makeself) using the same shell script header technique. Using tar precludes makeself from being used in plain text directly, but the better compression and other functionalities has made it more popular in the 21st century among software vendors seeking to package Linux software.

See also List of Unix commands

References

External links shar(1) – Linux General Commands Manual from ManKier.com "Information about shar files". Carnegie Mellon University. Archived from the original on 3 January 2011. GNU sharutils

Worked examples

Example 1 — a first encounter with Shar (file format)

Start with the simplest possible case. Write down what Shar (file format) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Shar (file format) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Shar (file format) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Shar (file format)

In research
Shar (file format) appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Shar (file format) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Shar (file format) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Archive formats, Unix archivers and compression-related utilities, so understanding it makes those chapters shorter.
In everyday life
Look for Shar (file format) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Shar (file format)” →

How to study Shar (file format) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Shar (file format) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Shar (file format) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Shar (file format) in simple terms?

In the Unix operating system, shar (from "shell archive") is an archive format created with the Unix shar utility. A shar file is a type of self-extracting archive, because it is a valid shell script, and executing it will recreate the files.

Why does Shar (file format) matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Shar (file format)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Shar (file format).

Tags

  • Archive formats
  • Unix archivers and compression-related utilities

Keep exploring