Save this video free

Lecture 7: Expansions; Introduction to scripting

Burton Ma · 47:02 · Watch on YouTube

Part of Queen's University CISC220. See all 23 lectures and search them

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

Burton Ma explains Bash’s seven expansion types, showing how constructs such as brace expansions, command substitutions, variables, and arithmetic expressions are replaced by their results. He then introduces Bash scripts as command sequences and demonstrates how shebang lines, executable permissions, and paths such as ./hello.sh make a script runnable.

Key takeaways

Chapters

0:00 Nested Brace Expansion Builds Multiple Path Strings
2:45 Tilde Expansion Selects a Home Directory
5:00 Command Substitution Inserts Command Output
11:15 Arithmetic Expansion Evaluates Integer Expressions
15:15 Word Splitting Can Break Filenames Containing Spaces
21:20 IFS Changes How Bash Splits Fields
28:55 Filename Expansion Completes the Seven-Expansion Overview
30:10 Shebang Lines Choose the Script Interpreter
37:10 Create and Run Scripts with Execute Permissions

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:02 Okay, good morning everybody. Um, so to remind you where we were at the end of the last class, we were in the expansions notebook. Uh, now recall exactly what an expansion is in bash. So an an expansion is some sort of construct in bash. Uh, where the expansion gets replaced by the result of performing the expansion. So we had almost finished looking at the brace expansion in bash. I'm just going to scroll down to where we were. Uh, and there's one last example. Um, so remember that a brace expansion in bash is something inside of braces. There might be a string in front of it, there might be a string after it. Um, and there inside the braces, there's either a commaepparated list of strings or there's something called a sequence

0:49 expression. Uh this particular example that I've got right uh up on the screen right now um is an example of a nested brace expansion. So you can see that there's um one expansion uh inside of a larger expansion. Um and to figure out exactly what this thing does, it's easiest just to run it and see what happens. And so what it does is it ends up outputting um in this case one two three four four different uh directory names right and if you trace through what's happening here it's not too difficult to figure out what's going on right there's a so the inner expansion oops sorry is going to produce two separate strings it's going to produce a string ex uh and it's going to produce a string edit

1:41 there's another uh there's There's a UCB here, right? So that shows up. Oop, sorry. There's a user UCB. Oh, sorry. There's a UCB here, and there's a lib here. Uh, and then there's another A and

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

In this course

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Burton Ma.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.