shar(1)
π shar(1) β User Commands π
Welcome to shar(1), bestie β a User Commands page with main character energy. This is part 1, so we're not wrapping up yet.
β¨ NAME β¨
shar β create a shell archive
πΈ SYNOPSIS πΈ
shar [-flags] [-flag [value]] [--option-name[[=| ]value]] [<file>...]
If no files are specified, the list of input files is read from standard input. Standard input must not be a terminal.
π¦ DESCRIPTION π¦
shar creates "shell archives" (or shar files) which are in text format and can be emailed. 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 fairly simple (--vanilla-operation) or essentially a mailable tar archive.
Options may be specified in any order until a file argument is recognized. If the --intermix-type option has been specified, more compression and encoding options will be recognized between the file arguments.
Though this program supports uuencode-d files, they are deprecated. If you are emailing files, please consider mime-encoded files. If you do uuencode, base64 is the preferred encoding method.
π OPTIONS π
ποΈ Specifying compression ποΈ
-p,--intermix-typeβ specify compression for input files. This option must not appear in combination with any of the following options:vanilla-operation.
Allow positional parameter options. The compression method and encoding method options may be intermixed with file names. Files named after these options will be processed in the specified way.
-C program,--compactor=programβ specify compaction (compression) program. This option may appear an unlimited number of times. This option must not appear in combination with any of the following options:vanilla-operation.
The gzip, bzip2 and compress compactor commands may be specified by the program name as the option name, e.g. --gzip. Those options, however, are being deprecated. There is also the xz compactor now. Specify xz with -C xz or --compactor=xz.
Specifying the compactor "none" will disable file compression. Compressed files are never processed as plain text. They are always uuencoded and the recipient must have uudecode to unpack them.
Specifying the compactor compress is deprecated.
-g level,--level-of-compression=levelβ passLEVELfor compression. This option takes an integer number as its argument. The value oflevelis constrained to being:- in the range
1through9
- in the range
The default level for this option is:
9
Some compression programs allow for a level of compression. The default is 9, but this option allows you to specify something else. This value is used by gzip, bzip2 and xz, but not compress.
-j,--bzip2β bzip2 and uuencode files. This option may appear an unlimited number of times.
bzip2 compress and uuencode all files prior to packing. The recipient must have uudecode bzip2 in order to unpack.
NOTE: THIS OPTION IS DEPRECATED
-z,--gzipβ gzip and uuencode files. This option may appear an unlimited number of times.
gzip compress and uuencode all files prior to packing. The recipient must have uudecode and gzip in order to unpack.
NOTE: THIS OPTION IS DEPRECATED
-Z,--compressβ compress and uuencode files. This option may appear an unlimited number of times.
compress and uuencode all files prior to packing. The recipient must have uudecode and compress in order to unpack.
NOTE: THIS OPTION IS DEPRECATED
--level-for-gzipβ This is an alias for the--level-of-compressionoption.
NOTE: THIS OPTION IS DEPRECATED
-b bits,--bits-per-code=bitsβ passbits(default12) tocompress. The default bits for this option is:12
This is the compression factor used by the compress program.
NOTE: THIS OPTION IS DEPRECATED
𧬠Specifying file encoding methodology π§¬
Files may be stored in the shar either as plain text or uuencoded. By default, the program selects which by examining the file. You may force the selection for all files. In intermixed option/file mode, this setting may be changed during processing.
-M,--mixed-uuencodeβ decide uuencoding for each file. This option is a member of themixed-uuencodeclass of options.
Automatically determine if the files are text or binary and archive correctly. Files found to be binary are uuencoded prior to packing. This is the default behavior for shar.
For a file to be considered a text file instead of a binary file, all the following should be true:
- The file does not contain any ASCII control character besides
BS(backspace),HT(horizontal tab),LF(new line) orFF(form feed). - The file contains no character with its eighth-bit set.
- The file contains no line beginning with the five letters
"from ", capitalized or not. (Mail handling programs will often gratuitously insert a>character before it.) - The file is either empty or ends with a
LF(newline) byte. - No line in the file contains more than 200 characters. For counting purpose, lines are separated by a
LF(newline).
-B,--uuencodeβ treat all files as binary. This option is a member of themixed-uuencodeclass of options.
Use uuencode prior to packing all files. This increases the size of the archive. The recipient must have uudecode in order to unpack. Compressed files are always encoded.
-T,--text-filesβ treat all files as text. This option is a member of themixed-uuencodeclass of options.
If you have files with non-ascii bytes or text that some mail handling programs do not like, you may find difficulties. However, if you are using FTP or SSH/SCP, the non-conforming text files should be okay.
ποΈ Specifying file selection and output modes ποΈ
-o prefix,--output-prefix=prefixβ print output to filePREFIX.nn.
Save the archive to files prefix.01 thru prefix.nn instead of sending all output to standard out. Must be specified when the --whole-size-limit or --split-size-limit options are specified.
When prefix contains a % character, prefix is then interpreted as a sprintf format, which should be able to display a single decimal number. When prefix does not contain such a % character, the string .%02d is internally appended.
-l size,--whole-size-limit=sizeβ split archive, not files, tosize. This option is a member of thewhole-size-limitclass of options. This option must appear in combination with the following options:output-prefix. This option takes an integer number as its argument. The value ofsizeis constrained to being:- in the range
8through1023, or - in the range
8192through4194304
- in the range
Limit the output file size to size bytes, but don't split input files. If size is less than 1024, then it will be multiplied by 1024. The value may also be specified with a k, K, m or M suffix. The number is then multiplied by 1000, 1024, 1000000, or 1048576, respectively. 4M (4194304) is the maximum allowed.
Unlike the split-size-limit option, this allows the recipient of the shar files to unpack them in any order.
-L size,--split-size-limit=sizeβ split archive or files tosize. This option is a member of thewhole-size-limitclass of options. This option must appear in combination with the following options:output-prefix. This option takes an integer number as its argument. The value ofsizeis constrained to being:- in the range
8through1023, or - in the range
8192through4194304
- in the range
Limit output file size to size bytes, splitting files if necessary. The allowed values are specified as with the --whole-size-limit option.
The archive parts created with this option must be unpacked in the correct order. If the recipient of the shell archives wants to put all of them in a single email folder (file), they will have to be saved in the correct order for unshar to unpack them all at once (using one of the split archive options). see: unshar Invocation.
-I file,--input-file-list=fileβ read file list from a file.
This option causes file to be reopened as standard input. If no files are found on the input line, then standard input is read for input file names. Use of this option will prohibit input files from being listed on the command line.
Input must be in a form similar to that generated by find, one filename per line. This switch is especially useful when the command line will not hold the list of files to be archived.
If the --intermix-type option is specified on the command line, then the compression options may be included in the standard input on lines by themselves and no file name may begin with a hyphen.
For example:
{ echo --compact xz
find . -type f -print | sort
} | shar -S -p -L50K -o /somewhere/big
-S,--stdin-file-listβ read file list from standard input.
This option is actually a no-op. It is a wrapper for --input-file-list=-.
NOTE: THIS OPTION IS DEPRECATED
π Controlling the shar headers π
-n name,--archive-name=nameβ usenameto document the archive.
Name of archive to be included in the subject header of the shar files. See the --net-headers option.
-s who@where,--submitter=who@whereβ override the submitter name.
shar will normally determine the submitter name by querying the system. Use this option if it is being done on behalf of another.
-a,--net-headersβ outputSubmitted-by:&Archive-name:headers. This option must appear in combination with the following options:archive-name.
Adds specialized email headers:
Submitted-by: who@@where
Archive-name: name/part##
The who@@where is normally derived, but can be specified with the --submitter option. The name must be provided with the --archive-name option. If the archive name includes a slash (/) character, then the /part## is omitted. Thus -n xyzzy produces:
xyzzy/part01
xyzzy/part02
while -n xyzzy/patch produces:
xyzzy/patch01
xyzzy/patch02
and -n xyzzy/patch01. produces:
xyzzy/patch01.01
xyzzy/patch01.02
-c,--cut-markβ start the shar with a cut line.
A line saying 'Cut here' is placed at the start of each output file.
-t,--translateβ translate messages in the script.
Translate messages in the script. If you have set the LANG environment variable, messages printed by shar will be in the specified language. The produced script will still be emitted using messages in the lingua franca of the computer world: English. This option will cause the script messages to appear in the languages specified by the LANG environment variable set when the script is produced.
π‘οΈ Protecting against transmission issues π‘οΈ
--no-character-countβ do not usewc -cto check size.
Do NOT check each file with 'wc -c' after unpack. The default is to check.
-D,--no-md5-digestβ bestie, this one says do not use md5sum digest to verify. The unpacked files just... don't get checked. Default is to check, so this is you choosing vibes over verification. π-F,--force-prefixβ apply the prefix character on every line. Like, every line, even the ones that don't strictly need it. Heads up though: this can slightly bulk up the size of your archive, especially if you're rolling with--uuencodeor a compression option. Lowkey worth it, highkey bigger file. π-ddelim,--here-delimiter=delimβ use delim to delimit the files. The default for this option is:
SHAR_EOF
Use DELIM to delimit the files in the shar instead of SHAR_EOF. This is for the girlies who wanna personalize their shar files β¨. FYI the delimiter will always be prefixed and suffixed with underscores. No exceptions, it's the rule.
π« Producing different kinds of shars π«
-V,--vanilla-operationβ produce very simple shars. We're talking vanilla-vanilla: this relies only uponecho,testandsedexisting in the unpacking environment. Nothing else, no extras. It flips the default behavior from mixed mode (--mixed-uuencode) over to text mode (--text-files). And if you specify options that would require decompression or decoding on the unpacking side, you'll get warnings, because that's not very vanilla of you. π¦-P,--no-pipingβ use temporary files between programs. In the shar file, use a temporary file to hold file contents between unpacking stages instead of using pipes. This one is mandatory when you know the unpacking will happen on systems that do not support pipes. It's giving "we don't have pipes here bestie" and that's fine. π«Ά-x,--no-check-existingβ blindly overwrite existing files. The archive gets created so that, when processed, it will overwrite existing files without checking first. If neither this option nor the--query-useroption is specified, the unpack will not overwrite pre-existing files. In all cases, though, if--cut-markis passed as a parameter to the script when unpacking, then existing files will be overwritten unconditionally:
sh shar-archive-file -c
Unconditional, no cap. π
-X,--query-userβ ask user before overwriting files. π¨ This option must not appear in combination with any of the following options:vanilla-operation. When unpacking, it interactively asks the user if files should be overwritten. Do not use for shars submitted to the net. fr fr, don't.
Use of this option produces shars which will cause problems with some unshar-style procedures, particularly when used together with vanilla mode (--vanilla-operation). Use this feature mainly for archives to be passed among agreeable parties. Certainly, -X is not for shell archives which are to be submitted to Usenet or other public networks.
The problem is that unshar programs or procedures often feed /bin/sh from its standard input, thus putting /bin/sh and the shell archive script in competition for input lines. π As an attempt to alleviate this problem, shar will try to detect if /dev/tty exists at the receiving site and will use it to read user replies. But this does not work in all cases, it may happen that the receiving user will have to avoid using unshar programs or procedures, and call /bin/sh directly. In vanilla mode, using /dev/tty is not even attempted.
-m,--no-timestampβ do not restore modification times. Avoid generatingtouchcommands to restore the file modification dates when unpacking files from the archive. When file modification times are not preserved, project build programs likemakewill see built files older than the files they get built from. Which is why, when this option is not used, a special effort is made to restore timestamps. β-Q,--quiet-unsharβ avoid verbose messages at unshar time. Verbose OFF. Disables the inclusion of comments to be output when the archive is unpacked. Shhh. π€«-f,--basenameβ restore in one directory, despite hierarchy. Restore by the base file name only, rather than path. This option causes only file names to be used, which is useful when building a shar from several directories, or another directory. Note that if a directory name is passed to shar, the substructure of that directory will be restored whether this option is specified or not. (Read that last bit twice, it's sneaky. π)
π Internationalization options π
--no-i18nβ do not internationalize. Do not produce internationalized shell archives, use default English messages. By default, shar produces archives that will try to output messages in the unpacker's preferred language (as determined by theLANG/LC_MESSAGESenvironmental variables) when they are unpacked. If no message file for the unpacker's language is found at unpack time, messages will be in English. π--print-text-domain-dirβ print directory with shar messages. Prints the directory shar looks in to find messages files for different languages, then immediately exits. Like a little peek behind the curtain, then she's gone. β¨
π User feedback/entertainment π
-q,--quietβ do not output verbose messages. omit progress messages.--silentβ This is an alias for the--quietoption.-h,--helpβ Display usage information and exit.-!,--more-helpβ Pass the extended usage information through a pager.-R[cfgfile],--save-opts[=cfgfile] β Save the option state to cfgfile. The default is the last configuration file listed in the OPTION PRESETS section, below. The command will exit after updating the config file.-rcfgfile,--load-opts=cfgfile,--no-load-optsβ Load options from cfgfile. Theno-load-optsform will disable the loading of earlier config/rc/ini files.--no-load-optsis handled early, out of order.-v[{v|c|n--version[{v|c|n}]}] β Output version of program and exit. The default mode isv, a simple version. Thecmode will print copyright information andnwill print the full copyright notice.
π OPTION PRESETS π
Any option that is not marked as not presettable may be preset by loading values from configuration ("RC" or ".INI") file(s). The file "$HOME/.sharrc" will be used, if present. Set it and forget it, bestie. π
π¨ WARNINGS π¨
No attempt is made to restore the protection and modification dates for directories, even if this is done by default for files. Thus, if a directory is given to shar, the protection and modification dates of the corresponding unpacked directory may not match those of the original. π
If a directory is passed to shar, it may be scanned more than once, to conserve memory. Therefore, do not change the directory contents while shar is running. Like, hands off the directory while she's working.
Be careful that the output file(s) are not included in the inputs or shar may loop until the disk fills up. π Be particularly careful when a directory is passed to shar that the output files are not in that directory or a subdirectory of it.
Use of the compression and encoding options will slow the archive process, perhaps considerably. Ngl, it's giving "patience is a virtue."
Use of the --query-user produces shars which will cause problems with many unshar procedures. Use this feature only for archives to be passed among agreeable parties. Certainly, query-user is NOT for shell archives which are to be distributed across the net. The use of compression in net shars will cause you to be flamed off the earth. π₯ Not using the --no-timestamp or --force-prefix options may also get you occasional complaints. Put these options into your ~/.sharrc file. Periodt. π
π FILES π
See OPTION PRESETS for configuration files.
β¨ EXAMPLES β¨
The first shows how to make a shell archive out of all C program sources. The second produces a shell archive with all .c and .h files, which unpacks silently. The third gives a shell archive of all uuencoded .arc files, into numbered files starting from arc.sh.01. The last example gives a shell archive which will use only the file names at unpack time.
shar *.c > cprog.shar
shar -Q *.[ch] > cprog.shar
shar -B -l28 -oarc.sh *.arc
shar -f /lcl/src/u*.c > u.sh
Four icons, four vibes. Copy them exactly, no editing. π
π¦ EXIT STATUS π¦
One of the following exit values will be returned:
0(EXIT_SUCCESS) β Successful program execution. We love to see it. π1(EXIT_OPTION_ERROR) β The command options were misconfigured.2(EXIT_FILE_NOT_FOUND) β a specified input could not be found3(EXIT_CANNOT_OPENDIR) β open/close of specified directory failed4(EXIT_FAILED) β Resource limit/miscelleaneous shar command failure63(EXIT_BUG) β There is a shar command bug. Please report it. π66(EX_NOINPUT) β A specified configuration file could not be loaded.70(EX_SOFTWARE) β libopts had an internal operational error. Please report it toautogen-users@lists.sourceforge.net. Thank you.
π SEE ALSO π
π AUTHORS π
The shar and unshar programs is the collective work of many authors. Many people contributed by reporting problems, suggesting various improvements or submitting actual code. A list of these people is in the THANKS file in the sharutils distribution. Absolute legends, every single one. π«Ά
βοΈ COPYRIGHT βοΈ
Copyright (C) 1994-2015 Free Software Foundation, Inc. all rights reserved. This program is released under the terms of the GNU General Public License, version 3 or later.
π BUGS π
Please put sharutils in the subject line for emailed bug reports. It helps to spot the message. π¬
Please send bug reports to: bug-gnu-utils@gnu.org
π NOTES π
This manual page was AutoGen-erated from the shar option definitions. (AutoGen-erated. She said what she said. β¨)
And that's the whole page, bestie β GNU sharutils 4.15.2, dated 30 May 2015, manual page shar(1). Go make some shell archives, you absolute icon. π
π
π¦ where this page comes from
- alpine 3.22: sharutils-doc 4.15.2-r6 Β· GPL-3.0-or-later
- alpine 3.23: sharutils-doc 4.15.2-r6 Β· GPL-3.0-or-later
- alpine 3.24: sharutils-doc 4.15.2-r6 Β· GPL-3.0-or-later
- arch rolling: sharutils 4.15.2-6 Β· GPL-3.0-or-later
- centos-stream 10: sharutils 4.15.2-28.el10 Β· GPL-3.0-or-later AND (GPL-3.0-or-later AND BSD-4-Clause) AND (LGPL-3.0-or-later OR BSD-3-Clause) AND LGPL-2.0-or-later AND LGPL-3.0-or-later AND LicenseRef-Fedora-Public-Domain AND GFDL-1.3-or-later
- centos-stream 9: sharutils 4.15.2-21.el9 Β· GPLv3+ and (GPLv3+ and BSD) and (LGPLv3+ or BSD) and LGPLv2+ and Public Domain and GFDL
- debian bookworm: sharutils 1:4.15.2-9
- debian trixie: sharutils 1:4.15.2-12
- fedora 43: sharutils 4.15.2-30.fc43 Β· GPL-3.0-or-later AND (GPL-3.0-or-later AND BSD-4-Clause) AND (LGPL-3.0-or-later OR BSD-3-Clause) AND LGPL-2.0-or-later AND LGPL-3.0-or-later AND LicenseRef-Fedora-Public-Domain AND GFDL-1.3-or-later
- fedora 44: sharutils 4.15.2-31.fc44 Β· GPL-3.0-or-later AND (GPL-3.0-or-later AND BSD-4-Clause) AND (LGPL-3.0-or-later OR BSD-3-Clause) AND LGPL-2.0-or-later AND LGPL-3.0-or-later AND LicenseRef-Fedora-Public-Domain AND GFDL-1.3-or-later
- nixos 26.05: sharutils 4.15.2
- nixpkgs unstable: sharutils 4.15.2
- opensuse-leap 16.0: sharutils 4.15.2-160000.2.2 Β· GPL-3.0-or-later
- opensuse-leap 16.0: sharutils 4.15.2-160000.2.2 Β· GPL-3.0-or-later
- opensuse-leap 16.0: sharutils 4.15.2-160000.2.2 Β· GPL-3.0-or-later
- opensuse-leap 16.0: sharutils 4.15.2-160000.2.2 Β· GPL-3.0-or-later
- ubuntu jammy: sharutils 1:4.15.2-5build1
- ubuntu noble: sharutils 1:4.15.2-9
- ubuntu questing: sharutils 1:4.15.2-12
- ubuntu resolute: sharutils 1:4.15.2-13
- ubuntu stonking: sharutils 1:4.15.2-13
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms