← 返回命令列表

Linux command

shar 命令

文件

涉及管道、覆盖或删除,执行前请先确认路径和参数。

常用示例

Example

shar -V [path/to/file1] [path/to/file2] > [archive.sh]

Example

shar -C xz [path/to/file1] [path/to/file2] > [archive.sh]

Example

shar -B [path/to/file1] [path/to/file2] > [archive.sh]

Example

shar -T [path/to/file1] [path/to/file2] > [archive.sh]

Example

shar -n "My Archive" -c [path/to/file1] > [archive.sh]

Split

shar -L 100K [path/to/file1] [path/to/file2] -o [archive]

说明

shar (shell archive) creates self-extracting archive files that can be unpacked by running them through /bin/sh. The archive is a plain text shell script containing the encoded file data, making it suitable for transmission via email or posting to text-based systems. Archives can contain multiple files and directories, with options for compression, binary encoding via uuencode, and splitting into multiple parts for size-limited transmission. To extract, run the archive with sh archive.sh or make it executable and run directly.

参数

-V, --vanilla-operation
Create minimal archives using only echo, test, sed
-B, --uuencode
Force uuencoding of all files (treat as binary)
-T, --text-files
Treat all input files as text
-M, --mixed-uuencode
Auto-detect binary vs text files (default)
-C, --compactor _program_
Compress files using gzip, bzip2, xz, or compress
-g, --level-of-compression _num_
Compression level 1-9 (default: 9)
-o, --output-prefix _str_
Save to numbered files (prefix.01, prefix.02, etc.)
-L, --split-size-limit _num_
Split archives to specified size
-n, --archive-name _str_
Document archive with name in headers
-c, --cut-mark
Start output with cut line
-a, --net-headers
Add Submitted-by and Archive-name headers
-x, --no-check-existing
Overwrite files without prompting on extraction
-m, --no-timestamp
Skip restoration of file modification times
-q, --quiet
Suppress progress messages
-h, --help
Display usage information

FAQ

What is the shar command used for?

shar (shell archive) creates self-extracting archive files that can be unpacked by running them through /bin/sh. The archive is a plain text shell script containing the encoded file data, making it suitable for transmission via email or posting to text-based systems. Archives can contain multiple files and directories, with options for compression, binary encoding via uuencode, and splitting into multiple parts for size-limited transmission. To extract, run the archive with sh archive.sh or make it executable and run directly.

How do I run a basic shar example?

Run `shar -V [path/to/file1] [path/to/file2] > [archive.sh]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -V, --vanilla-operation do in shar?

Create minimal archives using only echo, test, sed