Bash scripting is handy when you have a series of commands you know you’ll run regularly. In addition to using bash as a REPL (like I did above), which is also called using a command line interface, I can also write a “bash script”, which is a file that contains multiple commands, one per line, which can be run as a whole, instead of my having to do each one and wait for the REPL to give me another prompt to issue the next command.
You will notice that the title bar of the gif above contains the word “bash”. “bash” is short for Bourne shell, named after the creator of the early shell programming REPL. After each command I issue, the computer (in this case my MacBook Pro, which has a linux-like command line interface) reads and evaluates the command, prints any results to screen as needed, and loops back to await more instruction. In the above example, I ask the computer where I am ( pwd), list the files in my current directory ( ls), make a new directory ( mkdir), move into that directory ( cd), make a new blank file ( touch), and look into the file ( nano). If you’ve used the console in R (perhaps in RStudio), or a Jupyter Notebook, you’ve used a REPL. It allows you to work interactively with a computer system, so that you issue a command, the computer executes the command, gives output to your screen, and awaits further instruction.
#Mac terminal emulator windows software#
Want to learn more? Software Carpentry has a great series of educational resources in their course Shell Novice, which goes into greater detail than I can here. This article will get you started using a linux command line, using bash, with ease. How can you gain confidence and know what you’re doing? If you’ve generally always used a graphical user interface / GUI (like Windows or OSX, where you point and click to compute), moving into a CLI approach can be intimidating. So, you need to work in a command line interface (CLI) in a linux shell (a program that allows you to run commands on a Linux server or your Mac).