Shell series, part 1: from shell to scripting

Maciej Galeja
2 min readMay 18, 2024

Using Linux in programming means doing a lot of things in the console. Practically everything can be done there and probably most programmers do it this way. Our main way of interacting with the system is the console, and in it — one of the popular shells, usually bash or zsh.

sh, bash , zsh, ash , csh - these are all different languages, and code written in one often does not work directly in another.

In Linux, we can use shebang. Its task is to indicate which interpreter we want to use.

Working with containers requires caution. Running a script in, say, bash may be impossible due to the lack of an interpreter. In this case, the only solution is to rebuild the image and add the bash binary to it, and we do not always have control over the image.

Working with the shell is convenient: every action is represented by a command in text form, which can be copied and saved for future reference. These commands can also be saved in an executable file that can be run by the shell, known as a script.

Scripts often begin as a single command entered into the shell before evolving naturally into a script. As a result, the shell often becomes the primary language for automation.

These scripts are used in pipelines, and CI systems are built around them.

The extensive use of the shell has implications, which I will explore in this series of articles. Check this category for related articles.

Originally published at https://maciejgaleja.com on May 18, 2024.

--

--