what does adding sh do?

Solution 1:

sh stands for "shell" and shell is the old, Unix like command line interpreter. An interpreter is an program that executes specific instructions written in a programming or scripting language. So basically you say "Execute that file for me".

You must understand that Linux doesn't really look at the file extension in order to determine what the file (or program) is. So as long as the content of that file is written in a way that the sh interpreter understands, it will work. But just for the sake of readability, such files are normally given an .sh extension and I have no idea what the developer was thinking when he gave that file a .txt extension..

Solution 2:

In Ubuntu, sh or /bin/sh just points to dash. sh is supposed to run default command interpreter, which is dash for Ubuntu.1dash refers to Debian Almquist shell.

A shell is a command line interpreter for the system. There are several other shells like bash, csh, zsh etc. Here is a brief excerpt from man page of dash:

 The shell is a command that reads lines from either a file or the termi‐
 nal, interprets them, and generally executes other commands.  It is the
 program that is running when a user logs into the system (although a user
 can select a different shell with the chsh(1) command).  The shell imple‐
 ments a language that has flow control constructs, a macro facility that
 provides a variety of features in addition to data storage, along with
 built in history and line editing capabilities.  It incorporates many
 features to aid interactive use and has the advantage that the interpre‐
 tative language is common to both interactive and non-interactive use
 (shell scripts).  That is, commands can be typed directly to the running
 shell or can be put into a file and the file can be executed directly by
 the shell.

There are lot of tutorials about Linux shells, you can start with this Wikipedia Article.

Coming to your question, if you write sh file, dash executes file for you.