Introduction to Bash, VIM & Regex
Table of Contents
Introducing UNIXJames Halliday introduces Bash by placing its context with the history and background of Unix, an operating system first developed at AT&T Bell Labs in the 1960s.
Introducing the Unix ShellJames presents the Unix shell, a computer program that executes other computer programs, and its importance with the UNIX philosophy.
Using ShellAfter prompting students to open a terminal window and figuring out which shell they have installed on their computers, James demonstrates how to navigate through folders and files in an operating system through the terminal.
Introducting AliasesWhile students work on changing directories, James spends some moments demonstrating and writing temporary aliases. An alias is a stand-in or replacement of a word by another string mainly used for abbreviating a system command.
Special DirectoriesJames demonstrates special directories within the Bash shell that make it easier to navigate folders.
Combining and Copying FilesJames introduces to commands for files: The cat command, which concatenates many files into one file, and cp command, which can copy a file to another directory or file name.
Moving Files and Creating DirectoriesTo move files, James introduces the mv command. Afterward, James shows how to create a director with mkdir command and how to use tab to auto-complete directories.
Commands to Help Reduce Repetitive TypingAfter showing the wildcard character to matching files, James demonstrates how to use brace expansions, which allow for expanding patterns that would be repetitive to type out by hand.
Deleting Files and Counting WordsJames introduces the rm command file to remove files and directories. Then James shows how to use the wc command to count the number of lines, words, and bytes in a file.
Documentation and OptionsTo find the documentation at any time, James shows the man command that lists the commands that are available in the shell. Afterward, he demonstrates that options also called flags or switches, which are special arguments that can be passed onto shell command.
PathsJames demonstrates how to navigate to a file with absolute and relative paths.
Writing and Reading FilesJames introduces file redirects. Redirects can write the output of a command to a file, overwrite a file with new contents if it already exists.
PipesJames shows the pipe operator, which can feed the output of one program to the input of the next.
Curl, Grep, and PipelineJames demonstrates the curl command, which grabs data from or to a server using many protocols like HTTP or FTP. Using the curl command to grab a public domain text, James then shows how to chains commands until he figures out the number of types the word "whale" is used in Moby Dick.
head and tail commandsJames reviews the head and tail commands. Head command prints the first part of a file while the tail command reads from the end of the file.
Calendar and DatesJames shows how to print out the date with date command as well as showing the month or year with the cal command.
Shorten LinesJames demonstrates the fold command, which is used to shorten long lines.
More Curl and GrepJames reviews in more detail curl and grep.
Backticks and ArithmeticJames shows how to use backticks, which allow the output of a program in the arguments list of another. Then James illustrates how to do simple arithmetic at the command line.
Q&A: Watch and WeatherJames takes questions from students about the watch and the calendar commands.
Environment VariablesJames introduces environment variables, what are variables defined by the shell and shell scripts.
QuotesTo escape special characters from an argument, James introduces the use of quotes.
Bash Shell Scripts
Introducing ScriptsTo keep from writing the same sequence of commands repeatedly, James shows how to write and store a script that can be executed.
Read, Loops and WhileJames demonstrates the read command, which takes input from the keyboard and assigns it to a variable. After that, James covers loops that run a set of commands repeatedly. Then James expands upon the loop to show the while loop, execute a set of commands repeatedly until some condition occurs.
$PATHJames introduces the special environment variable $PATH
PermissionsJames explains that files on a UNIX system belong to a user or a group. Each group can have granular permission to write, edit, or view a file. Those permissions can be changed using the chmod command.
Exit Codes, Operators, and SubshellsJames illustrates an exit code, which is a code returned to a parent process by an executable. If the code is successful, the exit code is 0. Next James demonstrates the &&, ||, and ; operators. Then James demonstrates a subshell, which is a subprocess or child process of the parent shell.
Job ControlJames examples job control as a method Bash handling multiple programs running in parallel. James takes questions from students.
ScreenJames introduces screen, which allows multiple virtual windows in Unix.
Introducing Regular ExpressionsJames introduces Regular Expressions (regex or regexp), which is special text string for describing a search pattern or a search and replace command.
Flags, Metacharacters, and QuantifiersJames shows how to gain finer control over searches with Regular Expressions through the use of flags, metacharacters, and quantifiers.
Character Class RangesJames introduces characters classes, which commands Regular Expressions to match several sets of characters
Anchors, Groups, and sedTo have a search pattern check at the start of the beginning of a string, James shows anchoring within Regular Expressions. Then James demonstrates capture groups, which allow for targeting a number of letters or numbers. Next James introduces sed, a stream editor used to perform basic text transformations.
QA: Regular Expressions ReferenceJames shows the Perl Regular Expressions Reference as a useful tool that is probably already installed on your OS for researching syntaxes for Regular Expression. James takes questions from students.
Wrapping Up Regular ExpressionsJames wraps up Regular Expressions with some advice on how to keep on learning.
Introducing VimJames introduces Vim, an interactive text editor program for Unix that is popular for its rich features and as a development environment. The Vim editor supports ANSI codes that are special instructions that your terminal interprets and renders like moving the cursor around, change colors, or set editing modes.
Using VimJames shows how to use Vim to open, edit, and quit files.
Modes and Moving AroundJames demonstrates how to move within a document while editing within the Vim editor.
Deleting and SearchingAfter showing how to delete files, James demonstrates how to search within in a document with Regular Expressions. James takes questions from students.
Search and ReplaceJames demonstrates search and replace with Regular Expressions.
Visual SelectJames introduces visual mode, which is a flexible and easy mode to select a piece of text for an operator.
Paste Buffer and Insert ModesWithin visual mode, James introduces the paste buffer, which allows for copy and pasting. Then James introduces insert modes for finer control over the opening of files.
Wrapping up VimWhile wrapping up the course, James shows some tricks with Vim including inserting a file into another file; pipe commands within the editor; and remap characters for better editing experience.