Basics of BASH
Read this article if you
- Don’t know anything about BASH
- Want to learn some basic BASH commands
BASH stands for Bourne-Again SHell, as it was written to replace the Bourne shell.
BASH commands can be directly written into a shell, or can be placed into a .sh
script.
A shell is basically just your terminal. You will need a unix shell for these commands to work, which means either using MacOS, Linux or using WSL for Windows.
BASH Commands 🔗︎
Very simple commands that are pretty cool are things like cal
which returns a calendar, whoami
which returns your username. Other ones like cd
, ls
, date
are also useful.
These can be combined to create cool things.
Let’s look at creating a hello world script like hello_world.sh
All we need to write is the following
echo hello world
This prints ‘hello world’ to our screen, perfect!
BASH can do other incredible things. In fact, it’s almost just as good as any other programming language.
Here we can see a list of cool things you can do in bash: https://github.com/awesome-lists/awesome-bash
Things like
- minesweeper
- small http servers
Are just a small example of the things you can do in BASH.
You can even use something call cron
to automate your BASH scripts to run at certain times.
This is really useful for things like
- updating package managers
- backing up files
In fact, pushing information to this blog could very well be done as a cron job in BASH.
If you’d like to learn more about BASH functions etc, there is a useful tutorial here