What is Bash?
Bash is the command line shell you encounter when opening the terminal on most Unix operating systems, like Linux and macOS. Instead of typing the commands manually one by one in your terminal, you add all the commands in a text file and ask your OS shell to execute them all at once.
Bash is a comman language interpreter interacting with a computer from the command line. It’s also called a shell, because it surrounds the operating system kernel to hide its intricate details while allowing you the programmer to do imporant stuff like access data and write files by typing simple commands.
It provides a prompt where you can type a command which will then be interpreted by the shell and xecuted on the operating system to find out if you’re running bash type in which dollar sign shell from the command line, it’s like any other application that lives in the binaries directory.
Bash is also a programming language that allows us to write scripts, which means anything you type manually into command line can be automated with code when you first launch, the shell it actually runs a startup script that’s defined in the bash profile or bashrc file on your system.
Whenever you start a new session, you can add your own custom bash scripts to any project by creating a file that ends in file.sh for no file extension at all. You can also start writing commands like echo to print something and they’ll be interpreted line by line to create a variable.
Type a name in all caps followed by the equal sign, then reference it later in the script using a dollar sign in front of the name. Now, to execute the script, simply type the file name into the shell.
If you want to pass arguments when you run the script, positional arguments will automatically be assigned variable names of 1 2 3 and so on. In other cases you may need additional user input in the middle of a script, you can create loops in bash that will prompt the user to continue the script on a yes answer or exit on a no answer.
From there, we can implement conditional logic with an if statement which will test if the value on the left side is less than the value on the right side, if true, then run this command, otherwise, run the else command.
Run in Background
Last cool feature of the Bash is that you have multiple long running process. You can run them in parallel in the background by adding an ampersand after the command. These features are all about Bash, if you have any other feature, share with us.