This is not the current version of the class.

Data representation supplemental 1: Terminal and Docker


Terminal and command prompt

Digital Equipment Corporation (DEC) VT100

What’s a terminal?

Common shell utilities

Here are some commonly-installed, commonly-used programs that you can call directly from the shell. You may find them useful for testing. Documentation for these programs can be accessed via the man page, e.g. man cat, or often also through a help switch, e.g. cat --help.

Shell Program Description
cat Write named files (or standard input) to standard output.
wc Count lines, words, and characters in named files (or standard input).
head -n N Print first N lines of standard input.
head -c N Print first N characters of standard input.
tail -n N Print last N lines of standard input.
echo ARG1 ARG2... Print arguments to standard output.
printf FORMAT ARG... Print arguments with printf-style formatting.
true Always succeed (exit with status 0).
false Always fail (exit with status 1).
sort Sort lines in input.
uniq Drop duplicate lines in input (or print only duplicate lines).
tr Change characters; e.g., tr a-z A-Z makes all letters uppercase.
ps List processes.
curl URL Download URL and write result to standard output.
sleep N Pause for N seconds, then exit with status 0.
cut Cut selected portions of each line of a file.
grep PATTERN Print lines in named files (or standard input) that match a regular expression PATTERN.
tac Write lines in named files (or standard input) in reverse order to standard output.

Editing code in the terminal

Useful terminal keystrokes


Where does software run?




Another analogy

Plato’s cave


So what’s Docker?

Hello, world

Hello, world

#include <cstdio>

int main() {
    fprintf(stdout, "hello, world\n");

Standard input, standard output, and standard error

Redirecting output


Pipe to pager


Count bytes

“Write a program bc61 that counts the number of bytes in its standard input and prints the result to standard output. Use the fgetc and fprintf library functions for C-style I/O. Make sure you test your bc61 program with different inputs.”

Count words and lines

“Write a program wc61 that counts words and lines as well as bytes. A word is a sequence of one or more non-whitespace characters, and a line is zero or more bytes terminated by the newline character \n. Use the isspace library function, which is declared in the <cctype> header, to detect whitespace.”