Introduction
Welcome to our introduction to using the Bash shell. This session is composed of three one hour sessions
October 3, 5, and 6 from 2-3pm (Eastern Daylight Time)
and each session is a series of short live demos and exercises.
Each part builds on the previous parts, so it is best to attend the entire thing from start to end and to do the complete the execises. While we are starting assuming no prior knowledge of the command line, we will go quite far, so do not be off put if things seem pretty basic at the start.
Our training website https://training.sharcnet.ca has links to a readable version of today’s presentation in web, pdf, and epub format. You do not have to worry about taking notes or falling behind.
Zoom and Etiquette
Before getting started, we would like to introduce you to the online platform Zoom and discuss the online etiquette that we expect throughout the workshop.
First I would like to ask everyone to mute their microphone. You can do this by click the microphone icon. The microphone icon is in the far left of the menu that pops up on the bottom of the zoom window when you move your mouse on it. You know your microphone is muted when you see a red slash through the microphone icon.
It is good etiquette to leave your microphone off unless you are speaking as otherwise everyone will hear the background noise from your space, and we will be forced to mute you, which is something you cannot undo. If you want, you can also turn off your video by clicking the video camera icon to the immediate right of the microphone icon.
On the subject of ediquette, we want to maximize learning in these sessions by creating a welcoming and supportive environment for everyone regardless of background, identity, or knowledge level. Please be mindful to not engage in any behavior that is going to diminish the experience for any of the participants or the instructors.
One of the options in the bottom menu bar of the zoom window when you move your mouse over it is the people icon labeled Participants. Clicking this gives you a list of all the meeting participants. If you move the mouse over yourself, you will see you that a rename button appears. Please rename yourself if your current name does not reflect who you are.
Motivation
We are going to teach you the old school way of running your programs and processing your data with your keyboard and commands and not your mouse and menus. In the process, we hope that you will discover that the keyboard and commands, far from being archaic, are actually very well suited for automation and keep track of what you have done to repeat it or communicate it to others in the future.
As a small example, say we had collected 100 .data files in the Example folder and wanted to prefix them with today’s date. This would be a long tedious point and click session using a GUI
Using the command line though, it would only be four simple lines and complete in less than a second
today=$(date +%Y-%M-%d)
for file in *.data; do
mv $file $today-$file
done
It would also be trivial to save these lines in a file for future reference, share with a colleague, or incorporate them into a bigger set of commands to do more complex operations on the files. This last point is key. The command line composes. You can combine small bits into big bits, and big bits into bigger bits. This is extremely powerful. GUIs do not compose.