From the course: Linux System Engineer: Bash Shell Scripting for Automation
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
What makes a shell script a shell script?
From the course: Linux System Engineer: Bash Shell Scripting for Automation
What makes a shell script a shell script?
- [Lecturer] The beauty of shell scripting is that we don't need a complex development environment to get started. To make a shell script that acts like a system command, we do need to do a few things. First, we create a text file in our favorite editor. In the terminal, type in vi ~/script.sh then hit Enter. We've named it script.sh, so that vi will do syntax highlighting for us. Script don't have to be named like this, but it makes it nicer for text editors. Syntax highlighting makes debugging easier. For the next step, we need to edit the text file and make the first line point to the shell interpreter. We can do this by pointing it directly at the interpreter using an absolute path. When in insert mode by pressing I key and then add #!/bin/bash. In this case, we're specifying an absolute path to the bash interpreter executer ball. We can also use a second form. Change it to #!/usr/bin/env bash. In this case, we use the env command to search the system path for the bash…