Dev 101: Shell in a nutshell
In the Dev 101 series I cover some basic concepts of computer programming for a broad audience. I guess it’s the explanation I was looking for myself, when I first started out as a programmer…
In a previous installment of the Dev 101 series, I explained the concept of the shell — a command language interpreter that executes commands read from standard input, a command line string, or a specified file.
This means that shell can be used either interactively via the terminal:
tdeneire@XPS-13-9370:~$ sh
$ echo "hello"
hello
$ exit
tdeneire@XPS-13-9370:~$
or as a CLI:
sh -c "echo $(date)"
or to execute Shell scripts, saved as .sh
files like this:
#!/bin/shecho "Hello world"
You can then execute them with sh myfile.sh
Especially the last option is a fantastic tool for writing scripts for automation, installation, configuration, and so on.