Save this video free

Lecture 9: Variables (cont); Strings

Burton Ma · 40:35 · 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 which Bash expansions work in variable assignments, then demonstrates parameter substitutions for measuring, extracting, trimming, replacing, and changing the case of strings. He emphasizes that Bash string patterns use glob-style matching, that substitutions do not modify the original variable unless assigned back, and that students should memorize string length and substring syntax while looking up less-common forms.

Key takeaways

Chapters

0:00 Bash Assignments Skip Brace and Filename Expansion
5:30 Store Supported Expansion Results in Variables
7:30 Measure Strings and Extract Bash Substrings
14:40 Trim String Prefixes with Bash Glob Patterns
21:30 Extract File Names and Extensions with Prefix and Suffix Trimming
26:10 Replace or Delete Substrings with Slash Substitution
30:10 Convert String Case with Bash Parameter Patterns
37:50 What to Memorize About Bash String Substitution

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

Transcript excerpt

0:01 Okay. So, we were talking about expansions in the previous lecture. Um often when you perform an expansion, you'll want to store the result of the expansion in a variable so that you can process the expansion later on. Um one of the funny things about um bash though is that uh not all expansions occur when you try to perform an assignment. Right? So, what do I mean by that? So, here we've got some uh some examples of the 1 2 3 We have the six expansions uh that we've talked about previously. We've got the brace expansion here. Right? So, that hopefully that looks like it's going to produce the good, the bad, the ugly. Right? You've got another brace

0:48 expansion here where this one produces a sequence of values. Uh right there is file name expansion, right? So, that looks like I want all the file names that end in ipynb. That's the extension for all of the notebooks, if you're curious as to what that means. Right? Tilde expansion gives you back your home directory. We know that's parameter expansion, so when you access the value of a variable, that's parameter expansion. And there is an arithmetic expansion. So, inside double round brackets, you have an arithmetic expression. Right? And then the dollar dollar sign in front gives you the result of the arithmetic expression. So, if you run this, you get probably what you're hoping to get.

1:35 Right? So, you do get you do in fact get your brace expansion here and here. Right? You do in fact get a listing of all of the notebooks uh notebook files. Uh I get my home directory here. That's the tilde expansion. Uh there's your parameter expansion accessing the value of I forget what X uh and there's your the result of your

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.