When performing command line tasks or (CLI) jobs in Linux, it can become tedious when there is a lot to do, for instance, working as an administrator for a small/medium/large company. Automation is very helpful when parsing large files or running multiple commands at once more than one time a day. Scripts are basically text documents that run a series of commands in succession of one another. Think of it as writing for a play. Scripts use the #! sign at the top, this is known as a shabang. The shabang alerts Bash that the following text document is a script and should be ran as a succession of lines as such. The environment comes after the shabang like so: #!/bin/env/ replacing env with the environment the script is to be read from. Most Bash ran scripts have the environment of shell. Python and Ruby use their own environments respectively.
Bash and Shell are not usually the same things. Bash or Bourne Again Shell handles lots of commands very differently to regular shell. Shell doesn’t do well with complex tasks so for this reason, most complex scripts are written with #!/bin/bash. There are plenty of ways to do different tasks within bash, some commands are more complex for a more complex need, however, other complex code is used to show off a coder’s skills. Writing code in any sense tells a bit about the one writing it. Their thought processes and so on. When a developer of an os sets certain scripts to be ran from the system’s back end, many of these scripts use Anacron as a scheduler and they use #!/bin/sh as the environment. These scripts are usually found in the /etc /cron.daily monthly or weekly folders. These scripts usually consist of one or two lines to do tasks like updating the local database and updating man databases or rotating logs around.
Bash is good for most needs, however, it is imperative to plan out your next script with the job in mind. What am I trying to accomplish? Will this deal with numbers or strings? How will this work automated? In the next few tutorials I will go over some basic syntax for everyday commands. I will even talk more about Systemd timers and scheduling.