Download .SH Sample Files

Jump to:     File Information     Download     How to Open

What is an SH File?

An SH file is a shell script: a plain-text file of commands for a Unix shell such as Bash, sh or Zsh. Shell scripts automate tasks on Linux and macOS, from installing software to backups and server setup. The first line, called the shebang (for example #!/bin/bash), tells the system which shell should run the script.

You can run an SH file with bash script.sh, or make it executable with chmod +x script.sh and start it with ./script.sh. On Windows, shell scripts run in WSL, Git Bash or Cygwin.

Download SH Sample Files

Below are three short Bash scripts.

[91 bytes]
[225 bytes]
[78 bytes]

SH Sample File Details

SampleWhat it doesLinesFile size
Sample1.SHPrints three lines with echo, echo -n and echo -e491 bytes
Sample2.SHPrints a welcome message using variables, $USER and $HOSTNAME12225 bytes
Sample3.SHCounts from 0 to 4 in a while loop878 bytes

All three start with #!/bin/bash and use Windows (CRLF) line endings. That makes them a realistic test case, because Bash on Linux and macOS does not accept those line endings: running ./sample-1.sh fails with a “bad interpreter” error that mentions /bin/bash^M, and sample 3 stops with a syntax error. Convert the line endings first, then run the script:

# Remove the Windows carriage returns (or use dos2unix)
tr -d '\r' < sample-3.sh > sample-3-fixed.sh

$ bash sample-3-fixed.sh
Number: 0
Number: 1
Number: 2
Number: 3
Number: 4

What You Can Test With These SH Files

  • Line-ending handling: CRLF scripts in editors, Git (core.autocrlf) and tools such as dos2unix.
  • Linters: ShellCheck reports the carriage returns in these files.
  • Code editors: syntax highlighting for shell scripts.
  • CI and deployment pipelines: scripts written on Windows and run on Linux.
  • Upload filters: detecting or blocking executable scripts.

How to Check and Run an SH File

# Check the syntax without running the script
bash -n sample-2.sh

# Lint with ShellCheck
shellcheck sample-1.sh

# Make a script executable and run it (after fixing the line endings)
chmod +x sample-3-fixed.sh
./sample-3-fixed.sh

SH vs Other Script Files

Script typeExtensionRuns on
Shell script.shLinux, macOS and WSL
Batch file.batWindows Command Prompt
PowerShell script.ps1Windows, Linux and macOS with PowerShell
Python script.pyAny system with Python
Perl script.plAny system with Perl

The following programs can be used to open SH files: