Skip to content

SH (.sh)

.sh file signature | application/x-sh

SH is a shell script file format used by Unix-like systems, originating with the Bourne shell and maintained through POSIX-compatible shell implementations. It is used to automate command-line tasks, configure environments, start programs, and run installation or administration scripts. Because shell scripts can execute arbitrary commands, files from untrusted sources may alter systems, delete data, or download malware; review scripts before running them.

High

Magic Bytes

Offset 0
23 21 2F

Sources: Apache Tika

All Known Signatures

4 signature variants are documented for .sh files across multiple sources.

Hex Signature Offset Sources
23 21 2F 0 Apache Tika
23 21 20 2F 0 Apache Tika
23 21 09 2F 0 Apache Tika
65 76 61 6C 20 22 65 78 65 63 0 Apache Tika

Extension

.sh

MIME Type

application/x-sh

Byte Offset

0

Risk Level

High

Validation Code

How to validate .sh files in Python

Python
def is_sh(file_path: str) -> bool:
    """Check if file is a valid SH by magic bytes."""
    signature = bytes([0x23, 0x21, 0x2F])
    with open(file_path, "rb") as f:
        return f.read(3) == signature

How to validate .sh files in Node.js

Node.js
function isSH(buffer: Buffer): boolean {
  const signature = Buffer.from([0x23, 0x21, 0x2F]);
  return buffer.subarray(0, 3).equals(signature);
}

How to validate .sh files in Go

Go
func IsSH(data []byte) bool {
    signature := []byte{0x23, 0x21, 0x2F}
    if len(data) < 3 {
        return false
    }
    return bytes.Equal(data[:3], signature)
}

API Endpoint

GET /api/v1/sh
curl https://filesignature.org/api/v1/sh

See the full API documentation for all endpoints and parameters.

Related Formats

Frequently Asked Questions

What is a .sh file?

A .sh file is identified by the magic bytes 23 21 2F at byte offset 0. SH is a shell script file format used by Unix-like systems, originating with the Bourne shell and maintained through POSIX-compatible shell implementations. It is used to automate command-line tasks, configure environments, start programs, and run installation or administration scripts. Because shell scripts can execute arbitrary commands, files from untrusted sources may alter systems, delete data, or download malware; review scripts before running them.

What are the magic bytes for .sh files?

The magic bytes for SH files are 23 21 2F at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.

How do I validate a .sh file?

To validate a .sh file, read the first bytes of the file and compare them against the known magic bytes (23 21 2F) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.

What is the MIME type for .sh files?

The primary MIME type for .sh files is application/x-sh.

Is it safe to open .sh files?

SH (.sh) files are high risk because they can contain executable code. Never open .sh files from untrusted sources. Always scan with antivirus software, verify the source, and consider running in a sandboxed environment.