Using the Command Line

Several programs we’ll use extensively (da-extract-transcript, degreeAudit, and da-run-tests) are all “command line programs”. The command line is also a handy way to start the editor.

The “command line” is accessed via the Terminal program.

Common Commands

ls (list command)

The ls command lists what is in a directory. It starts in your “home directory”. Type ls at the prompt:

oat3 ~: ls
Desktop		Downloads	Movies		oat		Public
Documents	Library		Music		Pictures

These are the directories in your home directory. oat is pretty much the only one we’re interested in.

Execute ls oat and you’ll see the contents of that directory:

oat3 ~: ls oat
bin		oat-plandefs
oat3 ~: 

The contents of oat-plandefs is more interesting. Execute ls oat/oat-plandefs/uw/u/eng:

oat3 ~: ls oat/oat-plandefs/uw/u/eng 
bac				baseCourseDefs-1199.plan	baseCourseDefs-1229.plan	cred
baseCourseDefs-1179.plan	baseCourseDefs-1209.plan	baseCourseDefs-1239.plan
baseCourseDefs-1189.plan	baseCourseDefs-1219.plan	baseCourseDefs-1249.plan
oat3 ~: 

A couple of tips:

  • Type part of the “path” to a file or directory and terminal will complete it for you as far as it can. That is, type ls oat/o<TAB> and terminal will add at-plandefs/ for you. That’s called “command completion”.
  • Press tab again (when there is a choice of what to complete it with) and it will list the choices.
  • Use the up-arrow on your keyboard to view previous commands. Find one you’d like to repeat? Just hit Enter.

cd (change directory)

Terminal starts in your home directory, but you don’t have to stay there. For our work with degree audit, the most interesting directory will be the one containing the plan definitions. Change your current directory to that one with cd oat/oat-plandefs. Notice the prompt changed from oat3 ~: to oat3 oat-plandefs: to show that you’re now in oat-plandefs directory rather than the home directory (~).

Do an ls here and you’ll see the contents of the current directory:

oat3 oat-plandefs: ls
da-plan-approvers.csv	README.md		sql			test			uw
oat3 oat-plandefs: 

You can go back to your home directory with just cd (no arguments). You can go “up” a level in the directory structure with cd ... Each .. goes up one level.

Less Common Commands

There are other commands that we’ll reference in the subsequent documentation. We’ll summarize them here. If you’re working through the tutorial, go on to the next page.

more (display a text file)

more <FILE> will display the contents of <FILE> (replace <FILE> with something like actual/math/bac/cs/cs/csbhc-1189-grad.txt)

open (open a file using its default program)

This command is Mac-specific; I’m not sure if there is an equivalent on Windows or how it behaves.

File names generally have an “extension” such as .txt, .html, or .docx. On a Mac, open followed by the name of the file will use the program “registered” for that extension open the file. Unless someone has mucked with the registrations, open output/csbhc-1189-grad.html will open Safari (the Mac’s default browser) to display the file. The default program for .txt is TextEdit. That can be changed to a different editor (like VS Code!) by opening Finder, right-clicking on a file with that extension, and choosing Get Info.... Look for “Open with”, choose “Visual Studio Code”. Then click “Change All…”.