[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:00.40,0:00:02.86,Default,,0000,0000,0000,,Okay, welcome back. Dialogue: 0,0:00:02.86,0:00:05.92,Default,,0000,0000,0000,,Today we're gonna cover a couple separate Dialogue: 0,0:00:05.92,0:00:07.62,Default,,0000,0000,0000,,two main topics related to the shell. Dialogue: 0,0:00:07.62,0:00:11.24,Default,,0000,0000,0000,,First, we're gonna do some kind of shell\Nscripting, mainly related to bash, Dialogue: 0,0:00:11.24,0:00:14.16,Default,,0000,0000,0000,,which is the shell that most of you will start Dialogue: 0,0:00:14.16,0:00:18.52,Default,,0000,0000,0000,,in Mac, or like in most Linux systems,\Nthat's the default shell. Dialogue: 0,0:00:18.52,0:00:22.72,Default,,0000,0000,0000,,And it's also kind of backward compatible through\Nother shells like zsh, it's pretty nice. Dialogue: 0,0:00:22.74,0:00:25.94,Default,,0000,0000,0000,,And then we're gonna cover some other shell\Ntools that are really convenient, Dialogue: 0,0:00:26.06,0:00:29.32,Default,,0000,0000,0000,,so you avoid doing really repetitive tasks, Dialogue: 0,0:00:29.32,0:00:31.58,Default,,0000,0000,0000,,like looking for some piece of code Dialogue: 0,0:00:31.58,0:00:33.42,Default,,0000,0000,0000,,or for some elusive file. Dialogue: 0,0:00:33.42,0:00:36.16,Default,,0000,0000,0000,,And there are already really\Nnice built-in commands Dialogue: 0,0:00:36.16,0:00:40.96,Default,,0000,0000,0000,,that will really help you to do those things. Dialogue: 0,0:00:40.96,0:00:43.26,Default,,0000,0000,0000,,So yesterday we already kind of introduced Dialogue: 0,0:00:43.26,0:00:46.16,Default,,0000,0000,0000,,you to the shell and some of it's quirks, Dialogue: 0,0:00:46.16,0:00:48.72,Default,,0000,0000,0000,,and like how you start executing commands, Dialogue: 0,0:00:48.72,0:00:50.60,Default,,0000,0000,0000,,redirecting them. Dialogue: 0,0:00:50.60,0:00:52.40,Default,,0000,0000,0000,,Today, we're going to kind of cover more about Dialogue: 0,0:00:52.46,0:00:56.12,Default,,0000,0000,0000,,the syntax of the variables, the control flow, Dialogue: 0,0:00:56.12,0:00:57.72,Default,,0000,0000,0000,,functions of the shell. Dialogue: 0,0:00:57.72,0:01:02.70,Default,,0000,0000,0000,,So for example, once you drop\Ninto a shell, say you want to Dialogue: 0,0:01:02.76,0:01:06.36,Default,,0000,0000,0000,,define a variable, which is\None of the first things you Dialogue: 0,0:01:06.36,0:01:09.34,Default,,0000,0000,0000,,learn to do in a programming language. Dialogue: 0,0:01:09.34,0:01:12.74,Default,,0000,0000,0000,,Here you could do something like foo equals bar. Dialogue: 0,0:01:12.86,0:01:18.40,Default,,0000,0000,0000,,And now we can access the value\Nof foo by doing "$foo". Dialogue: 0,0:01:18.46,0:01:21.40,Default,,0000,0000,0000,,And that's bar, perfect. Dialogue: 0,0:01:21.40,0:01:24.48,Default,,0000,0000,0000,,One quirk that you need to be aware of is that Dialogue: 0,0:01:24.48,0:01:27.90,Default,,0000,0000,0000,,spaces are really critical when\Nyou're dealing with bash. Dialogue: 0,0:01:27.90,0:01:33.38,Default,,0000,0000,0000,,Mainly because spaces are reserved, and\Nthat will be for separating arguments. Dialogue: 0,0:01:33.38,0:01:36.70,Default,,0000,0000,0000,,So, for example, something like foo equals bar Dialogue: 0,0:01:36.70,0:01:42.00,Default,,0000,0000,0000,,won't work, and the shell is gonna\Ntell you why it's not working. Dialogue: 0,0:01:42.00,0:01:46.28,Default,,0000,0000,0000,,It's because the foo command is not\Nworking, like foo is non-existent. Dialogue: 0,0:01:46.28,0:01:47.78,Default,,0000,0000,0000,,And here what is actually happening,\Nwe're not assigning foo to bar, Dialogue: 0,0:01:47.78,0:01:52.26,Default,,0000,0000,0000,,what is happening is we're\Ncalling the foo program Dialogue: 0,0:01:52.26,0:01:57.52,Default,,0000,0000,0000,,with the first argument "=" and\Nthe second argument "bar". Dialogue: 0,0:01:57.52,0:02:03.88,Default,,0000,0000,0000,,And in general, whenever you are having\Nsome issues, like some files with spaces Dialogue: 0,0:02:03.88,0:02:06.16,Default,,0000,0000,0000,,you will need to be careful about that. Dialogue: 0,0:02:06.16,0:02:10.62,Default,,0000,0000,0000,,You need to be careful about quoting strings. Dialogue: 0,0:02:10.64,0:02:16.48,Default,,0000,0000,0000,,So, going into that, how you do strings in bash.\NThere are two ways that you can define a string: Dialogue: 0,0:02:16.54,0:02:24.72,Default,,0000,0000,0000,,You can define strings using double quotes\Nand you can define strings using single, Dialogue: 0,0:02:24.72,0:02:26.54,Default,,0000,0000,0000,,sorry, Dialogue: 0,0:02:26.54,0:02:28.88,Default,,0000,0000,0000,,using single quotes. Dialogue: 0,0:02:29.14,0:02:32.76,Default,,0000,0000,0000,,However, for literal strings they are equivalent, Dialogue: 0,0:02:32.76,0:02:35.46,Default,,0000,0000,0000,,but for the rest they are not equivalent. Dialogue: 0,0:02:35.46,0:02:42.98,Default,,0000,0000,0000,,So, for example, if we do value is $foo, Dialogue: 0,0:02:43.44,0:02:48.48,Default,,0000,0000,0000,,the $foo has been expanded like\Na string, substituted to the Dialogue: 0,0:02:48.48,0:02:50.82,Default,,0000,0000,0000,,value of the foo variable in the shell. Dialogue: 0,0:02:50.96,0:02:58.94,Default,,0000,0000,0000,,Whereas if we do this with a simple quote,\Nwe are just getting the $foo as it is Dialogue: 0,0:02:58.94,0:03:02.28,Default,,0000,0000,0000,,and single quotes won't be replacing. Again, Dialogue: 0,0:03:02.28,0:03:07.29,Default,,0000,0000,0000,,it's really easy to write a script, assume that\Nthis is kind of like Python, that you might be Dialogue: 0,0:03:07.29,0:03:10.86,Default,,0000,0000,0000,,more familiar with, and not realize all that. Dialogue: 0,0:03:10.86,0:03:14.18,Default,,0000,0000,0000,,And this is the way you will assign variables. Dialogue: 0,0:03:14.18,0:03:17.85,Default,,0000,0000,0000,,Then bash also has control flow\Ntechniques that we'll see later, Dialogue: 0,0:03:17.85,0:03:24.44,Default,,0000,0000,0000,,like for loops, while loops, and one main\Nthing is you can define functions. Dialogue: 0,0:03:24.44,0:03:27.82,Default,,0000,0000,0000,,We can access a function I have defined here. Dialogue: 0,0:03:28.22,0:03:34.22,Default,,0000,0000,0000,,Here we have the MCD function, that\Nhas been defined, and the thing is Dialogue: 0,0:03:34.22,0:03:38.40,Default,,0000,0000,0000,,so far, we have just kind of seen how\Nto execute several commands by piping Dialogue: 0,0:03:38.40,0:03:40.72,Default,,0000,0000,0000,,into them, kind of saw that briefly yesterday. Dialogue: 0,0:03:40.94,0:03:44.98,Default,,0000,0000,0000,,But a lot of times you want to do first\None thing and then another thing. Dialogue: 0,0:03:44.98,0:03:47.58,Default,,0000,0000,0000,,And that's kind of like the Dialogue: 0,0:03:47.74,0:03:50.88,Default,,0000,0000,0000,,sequential execution that we get here. Dialogue: 0,0:03:50.88,0:03:54.26,Default,,0000,0000,0000,,Here, for example, we're\Ncalling the MCD function. Dialogue: 0,0:03:56.86,0:03:57.80,Default,,0000,0000,0000,,We, first, Dialogue: 0,0:03:57.80,0:04:02.96,Default,,0000,0000,0000,,are calling the makedir command,\Nwhich is creating this directory. Dialogue: 0,0:04:02.96,0:04:05.60,Default,,0000,0000,0000,,Here, $1 is like a special variable. Dialogue: 0,0:04:05.60,0:04:07.44,Default,,0000,0000,0000,,This is the way that bash works, Dialogue: 0,0:04:07.44,0:04:12.16,Default,,0000,0000,0000,,whereas in other scripting languages\Nthere will be like argv, Dialogue: 0,0:04:12.16,0:04:16.62,Default,,0000,0000,0000,,the first item of the array argv\Nwill contain the argument. Dialogue: 0,0:04:16.62,0:04:19.16,Default,,0000,0000,0000,,In bash it's $1. And in general, a lot Dialogue: 0,0:04:19.16,0:04:21.64,Default,,0000,0000,0000,,of things in bash will be dollar something Dialogue: 0,0:04:21.64,0:04:26.68,Default,,0000,0000,0000,,and will be reserved, we will\Nbe seeing more examples later. Dialogue: 0,0:04:26.68,0:04:30.29,Default,,0000,0000,0000,,And once we have created the folder,\Nwe CD into that folder, Dialogue: 0,0:04:30.29,0:04:34.69,Default,,0000,0000,0000,,which is kind of a fairly common\Npattern that you will see. Dialogue: 0,0:04:34.69,0:04:39.06,Default,,0000,0000,0000,,We will actually type this directly\Ninto our shell, and it will work and Dialogue: 0,0:04:39.12,0:04:45.26,Default,,0000,0000,0000,,it will define this function. But sometimes\Nit's nicer to write things in a file. Dialogue: 0,0:04:45.26,0:04:50.04,Default,,0000,0000,0000,,What we can do is we can source\Nthis. And that will Dialogue: 0,0:04:50.08,0:04:53.96,Default,,0000,0000,0000,,execute this script in our shell and load it. Dialogue: 0,0:04:53.96,0:04:59.34,Default,,0000,0000,0000,,So now it looks like nothing happened,\Nbut now the MCD function has Dialogue: 0,0:04:59.34,0:05:03.46,Default,,0000,0000,0000,,been defined in our shell. So\Nwe can now for example do Dialogue: 0,0:05:03.46,0:05:09.15,Default,,0000,0000,0000,,MCD test, and now we move from\Nthe tools directory to the test Dialogue: 0,0:05:09.16,0:05:14.20,Default,,0000,0000,0000,,directory. We both created the\Nfolder and we moved into it. Dialogue: 0,0:05:15.76,0:05:18.82,Default,,0000,0000,0000,,What else. So a result is... Dialogue: 0,0:05:18.82,0:05:22.16,Default,,0000,0000,0000,,We can access the first argument with $1. Dialogue: 0,0:05:22.16,0:05:26.10,Default,,0000,0000,0000,,There's a lot more reserved commands, Dialogue: 0,0:05:26.10,0:05:30.02,Default,,0000,0000,0000,,for example $0 will be the name of the script, Dialogue: 0,0:05:30.02,0:05:35.26,Default,,0000,0000,0000,,$2 through $9 will be the second\Nthrough the ninth arguments Dialogue: 0,0:05:35.26,0:05:38.07,Default,,0000,0000,0000,,that the bash script takes.\NSome of these reserved Dialogue: 0,0:05:38.07,0:05:43.08,Default,,0000,0000,0000,,keywords can be directly used\Nin the shell, so for example Dialogue: 0,0:05:43.42,0:05:50.30,Default,,0000,0000,0000,,$? will get you the error code\Nfrom the previous command, Dialogue: 0,0:05:50.30,0:05:53.58,Default,,0000,0000,0000,,which I'll also explain briefly. Dialogue: 0,0:05:53.58,0:05:58.32,Default,,0000,0000,0000,,But for example, $_ will get\Nyou the last argument of the Dialogue: 0,0:05:58.32,0:06:03.46,Default,,0000,0000,0000,,previous command. So another way\Nwe could have done this is Dialogue: 0,0:06:03.46,0:06:07.38,Default,,0000,0000,0000,,we could have said like "mkdir test" Dialogue: 0,0:06:07.38,0:06:12.02,Default,,0000,0000,0000,,and instead of rewriting test, we\Ncan access that last argument Dialogue: 0,0:06:12.02,0:06:18.40,Default,,0000,0000,0000,,as part of the (previous command), using $_ Dialogue: 0,0:06:18.40,0:06:23.16,Default,,0000,0000,0000,,like, that will be replaced with\Ntest and now we go into test. Dialogue: 0,0:06:25.04,0:06:27.48,Default,,0000,0000,0000,,There are a lot of them, you\Nshould familiarize with them. Dialogue: 0,0:06:27.48,0:06:32.90,Default,,0000,0000,0000,,Another one I often use is called "bang\Nbang" ("!!"), you will run into this Dialogue: 0,0:06:32.91,0:06:37.30,Default,,0000,0000,0000,,whenever you, for example, are trying\Nto create something and you don't have Dialogue: 0,0:06:37.32,0:06:41.00,Default,,0000,0000,0000,,enough permissions. Then, you can do "sudo !!" Dialogue: 0,0:06:41.01,0:06:43.40,Default,,0000,0000,0000,,and then that will replace the command in Dialogue: 0,0:06:43.47,0:06:46.40,Default,,0000,0000,0000,,there and now you can just try doing Dialogue: 0,0:06:46.44,0:06:48.38,Default,,0000,0000,0000,,that. And now it will prompt you for a password, Dialogue: 0,0:06:48.38,0:06:50.08,Default,,0000,0000,0000,,because you have sudo permissions. Dialogue: 0,0:06:53.80,0:06:57.18,Default,,0000,0000,0000,,Before, I mentioned the, kind\Nof the error command. Dialogue: 0,0:06:57.18,0:06:59.40,Default,,0000,0000,0000,,Yesterday we saw that, in general, there are Dialogue: 0,0:06:59.40,0:07:02.40,Default,,0000,0000,0000,,different ways a process can communicate Dialogue: 0,0:07:02.40,0:07:05.09,Default,,0000,0000,0000,,with other processes or commands. Dialogue: 0,0:07:05.10,0:07:08.42,Default,,0000,0000,0000,,We mentioned the standard\Ninput, which also was like Dialogue: 0,0:07:09.16,0:07:11.38,Default,,0000,0000,0000,,getting stuff through the standard input, Dialogue: 0,0:07:11.64,0:07:13.84,Default,,0000,0000,0000,,putting stuff into the standard output. Dialogue: 0,0:07:13.84,0:07:16.83,Default,,0000,0000,0000,,There are a couple more interesting\Nthings, there's also like a Dialogue: 0,0:07:16.83,0:07:19.84,Default,,0000,0000,0000,,standard error, a stream where you write errors Dialogue: 0,0:07:19.84,0:07:23.90,Default,,0000,0000,0000,,that happen with your program and you don't\Nwant to pollute the standard output. Dialogue: 0,0:07:23.90,0:07:27.42,Default,,0000,0000,0000,,There's also the error code,\Nwhich is like a general Dialogue: 0,0:07:27.42,0:07:29.52,Default,,0000,0000,0000,,thing in a lot of programming languages, Dialogue: 0,0:07:29.52,0:07:34.46,Default,,0000,0000,0000,,some way of reporting how the\Nentire run of something went. Dialogue: 0,0:07:34.46,0:07:36.06,Default,,0000,0000,0000,,So if we do Dialogue: 0,0:07:36.06,0:07:41.02,Default,,0000,0000,0000,,something like echo hello and we Dialogue: 0,0:07:41.58,0:07:43.92,Default,,0000,0000,0000,,query for the value, it's zero. And it's zero Dialogue: 0,0:07:43.92,0:07:45.84,Default,,0000,0000,0000,,because everything went okay and there Dialogue: 0,0:07:45.84,0:07:49.17,Default,,0000,0000,0000,,weren't any issues. And a zero exit code is Dialogue: 0,0:07:49.17,0:07:50.94,Default,,0000,0000,0000,,the same as you will get in a language Dialogue: 0,0:07:50.94,0:07:54.98,Default,,0000,0000,0000,,like C, like 0 means everything\Nwent fine, there were no errors. Dialogue: 0,0:07:54.98,0:07:57.60,Default,,0000,0000,0000,,However, sometimes things won't work. Dialogue: 0,0:07:57.60,0:08:04.60,Default,,0000,0000,0000,,Sometimes, like if we try to grep\Nfor foobar in our MCD script, Dialogue: 0,0:08:04.60,0:08:08.13,Default,,0000,0000,0000,,and now we check for that\Nvalue, it's 1. And that's Dialogue: 0,0:08:08.13,0:08:10.77,Default,,0000,0000,0000,,because we tried to search for the foobar Dialogue: 0,0:08:10.77,0:08:13.62,Default,,0000,0000,0000,,string in the MCD script and it wasn't there. Dialogue: 0,0:08:13.62,0:08:17.19,Default,,0000,0000,0000,,So grep doesn't print anything, but Dialogue: 0,0:08:17.19,0:08:19.95,Default,,0000,0000,0000,,let us know that things didn't work by Dialogue: 0,0:08:19.95,0:08:22.26,Default,,0000,0000,0000,,giving us a 1 error code. Dialogue: 0,0:08:22.26,0:08:24.42,Default,,0000,0000,0000,,There are some interesting commands like Dialogue: 0,0:08:24.42,0:08:29.16,Default,,0000,0000,0000,,"true", for example, will always have a zero Dialogue: 0,0:08:29.16,0:08:35.06,Default,,0000,0000,0000,,error code, and false will always\Nhave a one error code. Dialogue: 0,0:08:35.06,0:08:37.92,Default,,0000,0000,0000,,Then there are like Dialogue: 0,0:08:37.92,0:08:40.08,Default,,0000,0000,0000,,these logical operators that you can use Dialogue: 0,0:08:40.08,0:08:43.81,Default,,0000,0000,0000,,to do some sort of conditionals.\NFor example, one way... Dialogue: 0,0:08:43.81,0:08:47.16,Default,,0000,0000,0000,,you also have IF's and ELSE's, that\Nwe will see later, but you can do Dialogue: 0,0:08:47.16,0:08:51.92,Default,,0000,0000,0000,,something like "false", and echo "Oops fail". Dialogue: 0,0:08:51.92,0:08:56.30,Default,,0000,0000,0000,,So here we have two commands connected\Nby this OR operator. Dialogue: 0,0:08:56.30,0:09:00.25,Default,,0000,0000,0000,,What bash is gonna do here, it's\Ngonna execute the first one Dialogue: 0,0:09:00.25,0:09:04.45,Default,,0000,0000,0000,,and if the first one didn't work, then it's Dialogue: 0,0:09:04.45,0:09:07.38,Default,,0000,0000,0000,,gonna execute the second one. So here we get it, Dialogue: 0,0:09:07.38,0:09:12.00,Default,,0000,0000,0000,,because it's gonna try to do a logical\NOR. If the first one didn't have Dialogue: 0,0:09:12.00,0:09:15.96,Default,,0000,0000,0000,,a zero error code, it's gonna try to\Ndo the second one. Similarly, if we Dialogue: 0,0:09:15.96,0:09:19.58,Default,,0000,0000,0000,,instead of use "false", we\Nuse something like "true", Dialogue: 0,0:09:19.58,0:09:22.18,Default,,0000,0000,0000,,since true will have a zero error code, then the Dialogue: 0,0:09:22.18,0:09:24.70,Default,,0000,0000,0000,,second one will be short-circuited and Dialogue: 0,0:09:24.70,0:09:27.50,Default,,0000,0000,0000,,it won't be printed. Dialogue: 0,0:09:32.56,0:09:36.97,Default,,0000,0000,0000,,Similarly, we have an AND\Noperator which will only Dialogue: 0,0:09:36.97,0:09:39.43,Default,,0000,0000,0000,,execute the second part if the first one Dialogue: 0,0:09:39.43,0:09:41.44,Default,,0000,0000,0000,,ran without errors. Dialogue: 0,0:09:41.44,0:09:44.82,Default,,0000,0000,0000,,And the same thing will happen. Dialogue: 0,0:09:44.82,0:09:50.34,Default,,0000,0000,0000,,If the first one fails, then the second\Npart of this thing won't be executed. Dialogue: 0,0:09:50.34,0:09:57.28,Default,,0000,0000,0000,,Kind of not exactly related to that, but\Nanother thing that you will see is Dialogue: 0,0:10:00.02,0:10:04.12,Default,,0000,0000,0000,,that no matter what you execute,\Nthen you can concatenate Dialogue: 0,0:10:04.12,0:10:07.12,Default,,0000,0000,0000,,commands using a semicolon in the same line, Dialogue: 0,0:10:07.12,0:10:10.30,Default,,0000,0000,0000,,and that will always print. Dialogue: 0,0:10:10.30,0:10:13.63,Default,,0000,0000,0000,,Beyond that, what we haven't\Nseen, for example, is how Dialogue: 0,0:10:13.63,0:10:19.46,Default,,0000,0000,0000,,you go about getting the output\Nof a command into a variable. Dialogue: 0,0:10:19.63,0:10:24.12,Default,,0000,0000,0000,,And the way we can do that is\Ndoing something like this. Dialogue: 0,0:10:24.12,0:10:29.48,Default,,0000,0000,0000,,What we're doing here is we're getting\Nthe output of the PWD command, Dialogue: 0,0:10:29.48,0:10:32.72,Default,,0000,0000,0000,,which is just printing the\Npresent working directory Dialogue: 0,0:10:32.72,0:10:33.74,Default,,0000,0000,0000,,where we are right now. Dialogue: 0,0:10:33.74,0:10:37.22,Default,,0000,0000,0000,,And then we're storing that\Ninto the foo variable. Dialogue: 0,0:10:37.22,0:10:42.28,Default,,0000,0000,0000,,So we do that and then we ask\Nfor foo, we view our string. Dialogue: 0,0:10:42.28,0:10:48.46,Default,,0000,0000,0000,,More generally, we can do this thing\Ncalled command substitution Dialogue: 0,0:10:50.11,0:10:51.50,Default,,0000,0000,0000,,by putting it into any string. Dialogue: 0,0:10:51.50,0:10:55.16,Default,,0000,0000,0000,,And since we're using double quotes\Ninstead of single quotes Dialogue: 0,0:10:55.16,0:10:57.44,Default,,0000,0000,0000,,that thing will be expanded and Dialogue: 0,0:10:57.44,0:11:02.74,Default,,0000,0000,0000,,it will tell us that we are\Nin this working folder. Dialogue: 0,0:11:02.74,0:11:09.24,Default,,0000,0000,0000,,Another interesting thing is, right now,\Nwhat this is expanding to is a string Dialogue: 0,0:11:09.40,0:11:10.30,Default,,0000,0000,0000,,instead of Dialogue: 0,0:11:11.92,0:11:13.32,Default,,0000,0000,0000,,It's just expanding as a string. Dialogue: 0,0:11:13.46,0:11:17.64,Default,,0000,0000,0000,,Another nifty and lesser known tool\Nis called process substitution, Dialogue: 0,0:11:17.64,0:11:20.54,Default,,0000,0000,0000,,which is kind of similar. What it will do... Dialogue: 0,0:11:24.36,0:11:30.04,Default,,0000,0000,0000,,it will, here for example, the "<(",\Nsome command and another parenthesis, Dialogue: 0,0:11:30.04,0:11:34.84,Default,,0000,0000,0000,,what that will do is: that will execute,\Nthat will get the output to Dialogue: 0,0:11:34.84,0:11:39.12,Default,,0000,0000,0000,,kind of like a temporary file and it will\Ngive the file handle to the command. Dialogue: 0,0:11:39.12,0:11:42.02,Default,,0000,0000,0000,,So here what we're doing is we're getting... Dialogue: 0,0:11:42.02,0:11:45.76,Default,,0000,0000,0000,,we're LS'ing the directory, putting\Nit into a temporary file, Dialogue: 0,0:11:45.76,0:11:48.04,Default,,0000,0000,0000,,doing the same thing for the\Nparent folder and then Dialogue: 0,0:11:48.04,0:11:51.31,Default,,0000,0000,0000,,we're concatenating both files. And this Dialogue: 0,0:11:51.31,0:11:55.52,Default,,0000,0000,0000,,will, may be really handy, because\Nsome commands instead of expecting Dialogue: 0,0:11:55.52,0:11:59.50,Default,,0000,0000,0000,,the input coming from the stdin,\Nthey are expecting things to Dialogue: 0,0:11:59.50,0:12:03.56,Default,,0000,0000,0000,,come from some file that is giving\Nsome of the arguments. Dialogue: 0,0:12:04.70,0:12:07.62,Default,,0000,0000,0000,,So we get both things concatenated. Dialogue: 0,0:12:12.88,0:12:17.04,Default,,0000,0000,0000,,I think so far there's been a lot of\Ninformation, let's see a simple, Dialogue: 0,0:12:17.04,0:12:22.92,Default,,0000,0000,0000,,an example script where we\Nsee a few of these things. Dialogue: 0,0:12:23.20,0:12:27.22,Default,,0000,0000,0000,,So for example here we have a string and we Dialogue: 0,0:12:27.22,0:12:30.33,Default,,0000,0000,0000,,have this $date. So $date is a program. Dialogue: 0,0:12:30.33,0:12:34.54,Default,,0000,0000,0000,,Again there's a lot of programs\Nin UNIX you will kind of slowly Dialogue: 0,0:12:34.54,0:12:36.12,Default,,0000,0000,0000,,familiarize with a lot of them. Dialogue: 0,0:12:36.12,0:12:42.82,Default,,0000,0000,0000,,Date just prints what the current date is\Nand you can specify different formats. Dialogue: 0,0:12:43.80,0:12:48.70,Default,,0000,0000,0000,,Then, we have these $0 here. $0 is the name Dialogue: 0,0:12:48.70,0:12:50.54,Default,,0000,0000,0000,,of the script that we're running. Dialogue: 0,0:12:50.55,0:12:56.59,Default,,0000,0000,0000,,Then we have $#, that's the number\Nof arguments that we are giving Dialogue: 0,0:12:56.59,0:13:01.92,Default,,0000,0000,0000,,to the command, and then $$ is the process\NID of this command that is running. Dialogue: 0,0:13:01.92,0:13:06.16,Default,,0000,0000,0000,,Again, there's a lot of these dollar\Nthings, they're not intuitive Dialogue: 0,0:13:06.16,0:13:07.69,Default,,0000,0000,0000,,because they don't have like a mnemonic Dialogue: 0,0:13:07.69,0:13:10.45,Default,,0000,0000,0000,,way of remembering, maybe, $#. But Dialogue: 0,0:13:10.45,0:13:12.88,Default,,0000,0000,0000,,it can be... you will just be Dialogue: 0,0:13:12.88,0:13:14.66,Default,,0000,0000,0000,,seeing them and getting familiar with them. Dialogue: 0,0:13:14.66,0:13:19.20,Default,,0000,0000,0000,,Here we have this $@, and that will\Nexpand to all the arguments. Dialogue: 0,0:13:19.20,0:13:21.48,Default,,0000,0000,0000,,So, instead of having to assume that, Dialogue: 0,0:13:21.49,0:13:25.84,Default,,0000,0000,0000,,maybe say, we have three arguments\Nand writing $1, $2, $3, Dialogue: 0,0:13:25.84,0:13:29.76,Default,,0000,0000,0000,,if we don't know how many arguments we\Ncan put all those arguments there. Dialogue: 0,0:13:29.76,0:13:33.67,Default,,0000,0000,0000,,And that has been given to a\Nfor loop. And the for loop Dialogue: 0,0:13:33.67,0:13:39.02,Default,,0000,0000,0000,,will, in time, get the file variable Dialogue: 0,0:13:39.02,0:13:43.88,Default,,0000,0000,0000,,and it will be giving each one of the arguments. Dialogue: 0,0:13:43.88,0:13:47.53,Default,,0000,0000,0000,,So what we're doing is, for every\None of the arguments we're giving. Dialogue: 0,0:13:47.53,0:13:51.70,Default,,0000,0000,0000,,Then, in the next line we're running the Dialogue: 0,0:13:51.70,0:13:56.92,Default,,0000,0000,0000,,grep command which is just search for\Na substring in some file and we're Dialogue: 0,0:13:56.92,0:14:01.38,Default,,0000,0000,0000,,searching for the string foobar in the file. Dialogue: 0,0:14:01.38,0:14:06.49,Default,,0000,0000,0000,,Here, we have put the variable\Nthat the file took, to expand. Dialogue: 0,0:14:06.49,0:14:11.56,Default,,0000,0000,0000,,And yesterday we saw that if we care\Nabout the output of a program, we can Dialogue: 0,0:14:11.56,0:14:15.68,Default,,0000,0000,0000,,redirect it to somewhere, to save it\Nor to connect it to some other file. Dialogue: 0,0:14:15.68,0:14:18.94,Default,,0000,0000,0000,,But sometimes you want the opposite. Dialogue: 0,0:14:18.94,0:14:21.26,Default,,0000,0000,0000,,Sometimes, here for example, we care... Dialogue: 0,0:14:21.26,0:14:25.12,Default,,0000,0000,0000,,we're gonna care about the error code. About\Nthis script, we're gonna care whether the Dialogue: 0,0:14:25.12,0:14:28.44,Default,,0000,0000,0000,,grep ran successfully or it didn't. Dialogue: 0,0:14:28.44,0:14:33.22,Default,,0000,0000,0000,,So we can actually discard\Nentirely what the output... Dialogue: 0,0:14:33.22,0:14:37.48,Default,,0000,0000,0000,,like both the standard output and the\Nstandard error of the grep command. Dialogue: 0,0:14:37.48,0:14:39.97,Default,,0000,0000,0000,,And what we're doing is we're Dialogue: 0,0:14:39.97,0:14:43.03,Default,,0000,0000,0000,,redirecting the output to /dev/null which Dialogue: 0,0:14:43.03,0:14:46.54,Default,,0000,0000,0000,,is kind of like a special device in UNIX Dialogue: 0,0:14:46.54,0:14:49.12,Default,,0000,0000,0000,,systems where you can like write and Dialogue: 0,0:14:49.12,0:14:51.13,Default,,0000,0000,0000,,it will be discarded. Like you can Dialogue: 0,0:14:51.13,0:14:52.87,Default,,0000,0000,0000,,write no matter how much you want, Dialogue: 0,0:14:52.87,0:14:57.73,Default,,0000,0000,0000,,there, and it will be discarded.\NAnd here's the ">" symbol Dialogue: 0,0:14:57.73,0:15:02.20,Default,,0000,0000,0000,,that we saw yesterday for redirecting\Noutput. Here you have a "2>" Dialogue: 0,0:15:02.20,0:15:04.69,Default,,0000,0000,0000,,and, as some of you might have Dialogue: 0,0:15:04.69,0:15:06.52,Default,,0000,0000,0000,,guessed by now, this is for redirecting the Dialogue: 0,0:15:06.52,0:15:08.59,Default,,0000,0000,0000,,standard error, because those those two Dialogue: 0,0:15:08.59,0:15:11.71,Default,,0000,0000,0000,,streams are separate, and you kind of have to Dialogue: 0,0:15:11.71,0:15:14.64,Default,,0000,0000,0000,,tell bash what to do with each one of them. Dialogue: 0,0:15:14.64,0:15:17.53,Default,,0000,0000,0000,,So here, we run, we check if the file has Dialogue: 0,0:15:17.53,0:15:20.65,Default,,0000,0000,0000,,foobar, and if the file has foobar then it's Dialogue: 0,0:15:20.65,0:15:22.96,Default,,0000,0000,0000,,going to have a zero code. If it Dialogue: 0,0:15:22.96,0:15:24.37,Default,,0000,0000,0000,,doesn't have foobar, it's gonna have a Dialogue: 0,0:15:24.37,0:15:26.98,Default,,0000,0000,0000,,nonzero error code. So that's exactly what we Dialogue: 0,0:15:26.98,0:15:31.12,Default,,0000,0000,0000,,check. In this if part of the command we Dialogue: 0,0:15:31.12,0:15:34.84,Default,,0000,0000,0000,,say "get me the error code". Again, this $? Dialogue: 0,0:15:34.84,0:15:37.24,Default,,0000,0000,0000,,And then we have a comparison operator Dialogue: 0,0:15:37.24,0:15:41.59,Default,,0000,0000,0000,,which is "-ne", for "non equal". And some Dialogue: 0,0:15:41.59,0:15:47.65,Default,,0000,0000,0000,,other programming languages\Nwill have "==", "!=", these Dialogue: 0,0:15:47.65,0:15:51.07,Default,,0000,0000,0000,,symbols. In bash there's Dialogue: 0,0:15:51.07,0:15:53.65,Default,,0000,0000,0000,,like a reserved set of comparisons and Dialogue: 0,0:15:53.65,0:15:54.97,Default,,0000,0000,0000,,it's mainly because there's a lot of Dialogue: 0,0:15:54.97,0:15:57.52,Default,,0000,0000,0000,,things you might want to test for when Dialogue: 0,0:15:57.52,0:15:59.08,Default,,0000,0000,0000,,you're in the shell. Here for example Dialogue: 0,0:15:59.08,0:16:03.97,Default,,0000,0000,0000,,we're just checking for two values, two\Ninteger values, being the same. Or for Dialogue: 0,0:16:03.97,0:16:08.38,Default,,0000,0000,0000,,example here, the "-F" check will let Dialogue: 0,0:16:08.38,0:16:10.42,Default,,0000,0000,0000,,us know if a file exists, which is Dialogue: 0,0:16:10.42,0:16:12.22,Default,,0000,0000,0000,,something that you will run into very, Dialogue: 0,0:16:12.22,0:16:17.53,Default,,0000,0000,0000,,very commonly. I'm going back to the Dialogue: 0,0:16:17.53,0:16:23.02,Default,,0000,0000,0000,,example. Then, what happens when we Dialogue: 0,0:16:24.40,0:16:28.60,Default,,0000,0000,0000,,if the file did not have\Nfoobar, like there was a Dialogue: 0,0:16:28.60,0:16:31.99,Default,,0000,0000,0000,,nonzero error code, then we print Dialogue: 0,0:16:31.99,0:16:33.40,Default,,0000,0000,0000,,"this file doesn't have any foobar, Dialogue: 0,0:16:33.40,0:16:36.40,Default,,0000,0000,0000,,we're going to add one". And what we do is Dialogue: 0,0:16:36.40,0:16:40.75,Default,,0000,0000,0000,,we echo this "# foobar", hoping this Dialogue: 0,0:16:40.75,0:16:43.20,Default,,0000,0000,0000,,is a comment to the file and then we're Dialogue: 0,0:16:43.20,0:16:47.62,Default,,0000,0000,0000,,using the operator ">>" to append at the end of Dialogue: 0,0:16:47.62,0:16:50.80,Default,,0000,0000,0000,,the file. Here since the file has Dialogue: 0,0:16:50.80,0:16:54.49,Default,,0000,0000,0000,,been fed through the script, and we don't\Nknow it beforehand, we have to substitute Dialogue: 0,0:16:54.49,0:17:03.43,Default,,0000,0000,0000,,the variable of the filename. We can\Nactually run this. We already have Dialogue: 0,0:17:03.43,0:17:05.26,Default,,0000,0000,0000,,correct permissions in this script and Dialogue: 0,0:17:05.26,0:17:10.54,Default,,0000,0000,0000,,we can give a few examples. We have a\Nfew files in this folder, "mcd" is the Dialogue: 0,0:17:10.54,0:17:12.76,Default,,0000,0000,0000,,one we saw at the beginning for the MCD Dialogue: 0,0:17:12.76,0:17:15.04,Default,,0000,0000,0000,,function, some other "script" function and Dialogue: 0,0:17:15.04,0:17:21.70,Default,,0000,0000,0000,,we can even feed the own script to itself\Nto check if it has foobar in it. Dialogue: 0,0:17:21.70,0:17:26.68,Default,,0000,0000,0000,,And we run it and first we can\Nsee that there's different Dialogue: 0,0:17:26.68,0:17:29.46,Default,,0000,0000,0000,,variables that we saw, that have been Dialogue: 0,0:17:29.46,0:17:33.40,Default,,0000,0000,0000,,successfully expanded. We have the date, that has Dialogue: 0,0:17:33.40,0:17:36.70,Default,,0000,0000,0000,,been replaced to the current time, then Dialogue: 0,0:17:36.70,0:17:39.10,Default,,0000,0000,0000,,we're running this program, with three Dialogue: 0,0:17:39.10,0:17:44.56,Default,,0000,0000,0000,,arguments, this randomized PID, and then Dialogue: 0,0:17:44.56,0:17:46.51,Default,,0000,0000,0000,,it's telling us MCD doesn't have any Dialogue: 0,0:17:46.51,0:17:48.17,Default,,0000,0000,0000,,foobar, so we are adding a new one, Dialogue: 0,0:17:48.17,0:17:50.45,Default,,0000,0000,0000,,and this script file doesn't Dialogue: 0,0:17:50.45,0:17:52.97,Default,,0000,0000,0000,,have one. So now for example let's look at MCD Dialogue: 0,0:17:52.97,0:17:55.82,Default,,0000,0000,0000,,and it has the comment that we were looking for. Dialogue: 0,0:17:59.00,0:18:05.62,Default,,0000,0000,0000,,One other thing to know when you're\Nexecuting scripts is that Dialogue: 0,0:18:05.62,0:18:07.76,Default,,0000,0000,0000,,here we have like three completely Dialogue: 0,0:18:07.76,0:18:10.28,Default,,0000,0000,0000,,different arguments but very commonly Dialogue: 0,0:18:10.28,0:18:12.89,Default,,0000,0000,0000,,you will be giving arguments that Dialogue: 0,0:18:12.89,0:18:16.10,Default,,0000,0000,0000,,can be more succinctly given in some way. Dialogue: 0,0:18:16.10,0:18:20.18,Default,,0000,0000,0000,,So for example here if we wanted to Dialogue: 0,0:18:20.18,0:18:25.43,Default,,0000,0000,0000,,refer to all the ".sh" scripts we Dialogue: 0,0:18:25.43,0:18:31.12,Default,,0000,0000,0000,,could just do something like "ls *.sh" Dialogue: 0,0:18:31.12,0:18:36.12,Default,,0000,0000,0000,,and this is a way of filename expansion\Nthat most shells have Dialogue: 0,0:18:36.12,0:18:38.45,Default,,0000,0000,0000,,that's called "globbing". Here, as you Dialogue: 0,0:18:38.45,0:18:39.92,Default,,0000,0000,0000,,might expect, this is gonna say Dialogue: 0,0:18:39.92,0:18:42.56,Default,,0000,0000,0000,,anything that has any kind of sort of Dialogue: 0,0:18:42.56,0:18:45.94,Default,,0000,0000,0000,,characters and ends up with "sh". Dialogue: 0,0:18:45.94,0:18:52.16,Default,,0000,0000,0000,,Unsurprisingly, we get "example.sh"\Nand "mcd.sh". We also have these Dialogue: 0,0:18:52.16,0:18:54.77,Default,,0000,0000,0000,,"project1" and "project2", and if there Dialogue: 0,0:18:54.77,0:19:00.10,Default,,0000,0000,0000,,were like a... we can do a\N"project42", for example Dialogue: 0,0:19:00.62,0:19:04.22,Default,,0000,0000,0000,,And now if we just want to refer\Nto the projects that have Dialogue: 0,0:19:04.22,0:19:07.28,Default,,0000,0000,0000,,a single character, but not two characters Dialogue: 0,0:19:07.28,0:19:08.72,Default,,0000,0000,0000,,afterwards, like any other characters, Dialogue: 0,0:19:08.72,0:19:13.88,Default,,0000,0000,0000,,we can use the question mark. So "?"\Nwill expand to only a single one. Dialogue: 0,0:19:13.88,0:19:17.36,Default,,0000,0000,0000,,And we get, LS'ing, first Dialogue: 0,0:19:17.36,0:19:21.05,Default,,0000,0000,0000,,"project1" and then "project2". Dialogue: 0,0:19:21.05,0:19:27.58,Default,,0000,0000,0000,,In general, globbing can be very powerful.\NYou can also combine it. Dialogue: 0,0:19:31.88,0:19:35.48,Default,,0000,0000,0000,,A common pattern is to use what\Nis called curly braces. Dialogue: 0,0:19:35.48,0:19:39.32,Default,,0000,0000,0000,,So let's say we have an image,\Nthat we have in this folder Dialogue: 0,0:19:39.32,0:19:43.62,Default,,0000,0000,0000,,and we want to convert this image from PNG to JPG Dialogue: 0,0:19:43.62,0:19:46.32,Default,,0000,0000,0000,,or we could maybe copy it, or... Dialogue: 0,0:19:46.32,0:19:49.61,Default,,0000,0000,0000,,it's a really common pattern, to have\Ntwo or more arguments that are Dialogue: 0,0:19:49.61,0:19:55.24,Default,,0000,0000,0000,,fairly similar and you want to do something\Nwith them as arguments to some command. Dialogue: 0,0:19:55.24,0:20:01.29,Default,,0000,0000,0000,,You could do it this way, or more\Nsuccinctly, you can just do Dialogue: 0,0:20:01.29,0:20:08.88,Default,,0000,0000,0000,,"image.{png,jpg}" Dialogue: 0,0:20:09.41,0:20:13.59,Default,,0000,0000,0000,,And here, I'm getting some color feedback,\Nbut what this will do, is Dialogue: 0,0:20:13.59,0:20:17.61,Default,,0000,0000,0000,,it'll expand into the line above. Dialogue: 0,0:20:17.61,0:20:23.99,Default,,0000,0000,0000,,Actually, I can ask zsh to do that for\Nme. And that what's happening here. Dialogue: 0,0:20:23.99,0:20:26.55,Default,,0000,0000,0000,,This is really powerful. So for example Dialogue: 0,0:20:26.55,0:20:29.22,Default,,0000,0000,0000,,you can do something like... we could do... Dialogue: 0,0:20:29.22,0:20:34.22,Default,,0000,0000,0000,,"touch" on a bunch of foo's, and\Nall of this will be expanded. Dialogue: 0,0:20:35.52,0:20:41.88,Default,,0000,0000,0000,,You can also do it at several levels\Nand you will do the Cartesian... Dialogue: 0,0:20:41.88,0:20:49.98,Default,,0000,0000,0000,,if we have something like this,\Nwe have one group here, "{1,2}" Dialogue: 0,0:20:49.98,0:20:53.31,Default,,0000,0000,0000,,and then here there's "{1,2,3}",\Nand this is going to do Dialogue: 0,0:20:53.31,0:20:54.99,Default,,0000,0000,0000,,the Cartesian product of these Dialogue: 0,0:20:54.99,0:20:59.92,Default,,0000,0000,0000,,two expansions and it will expand\Ninto all these things, Dialogue: 0,0:20:59.96,0:21:03.54,Default,,0000,0000,0000,,that we can quickly "touch". Dialogue: 0,0:21:03.54,0:21:10.52,Default,,0000,0000,0000,,You can also combine the asterisk\Nglob with the curly braces glob. Dialogue: 0,0:21:10.52,0:21:16.84,Default,,0000,0000,0000,,You can even use kind of ranges.\NLike, we can do "mkdir" Dialogue: 0,0:21:16.84,0:21:21.42,Default,,0000,0000,0000,,and we create the "foo" and the\N"bar" directories, and then we Dialogue: 0,0:21:21.42,0:21:25.68,Default,,0000,0000,0000,,can do something along these lines. This Dialogue: 0,0:21:25.68,0:21:28.89,Default,,0000,0000,0000,,is going to expand to "fooa", "foob"... Dialogue: 0,0:21:28.89,0:21:31.43,Default,,0000,0000,0000,,like all these combinations, through "j", and Dialogue: 0,0:21:31.43,0:21:35.25,Default,,0000,0000,0000,,then the same for "bar". I haven't Dialogue: 0,0:21:35.25,0:21:38.61,Default,,0000,0000,0000,,really tested it... but yeah, we're getting\Nall these combinations that we Dialogue: 0,0:21:38.61,0:21:41.85,Default,,0000,0000,0000,,can "touch". And now, if we touch something Dialogue: 0,0:21:41.85,0:21:47.97,Default,,0000,0000,0000,,that is different between these\Ntwo [directories], we Dialogue: 0,0:21:47.97,0:21:55.89,Default,,0000,0000,0000,,can again showcase the process\Nsubstitution that we saw Dialogue: 0,0:21:55.89,0:21:59.61,Default,,0000,0000,0000,,earlier. Say we want to check what\Nfiles are different between these Dialogue: 0,0:21:59.61,0:22:03.40,Default,,0000,0000,0000,,two folders. For us it's obvious,\Nwe just saw it, it's X and Y, Dialogue: 0,0:22:03.40,0:22:07.41,Default,,0000,0000,0000,,but we can ask the shell to do\Nthis "diff" for us between the Dialogue: 0,0:22:07.41,0:22:10.20,Default,,0000,0000,0000,,output of one LS and the other LS. Dialogue: 0,0:22:10.20,0:22:12.81,Default,,0000,0000,0000,,Unsurprisingly we're getting: X is Dialogue: 0,0:22:12.81,0:22:14.70,Default,,0000,0000,0000,,only in the first folder and Y is Dialogue: 0,0:22:14.70,0:22:20.97,Default,,0000,0000,0000,,only in the second folder. What is more Dialogue: 0,0:22:20.97,0:22:26.52,Default,,0000,0000,0000,,is, right now, we have only seen\Nbash scripts. If you like other Dialogue: 0,0:22:26.52,0:22:30.26,Default,,0000,0000,0000,,scripts, like for some tasks bash\Nis probably not the best, Dialogue: 0,0:22:30.26,0:22:33.12,Default,,0000,0000,0000,,it can be tricky. You can actually\Nwrite scripts that Dialogue: 0,0:22:33.12,0:22:35.70,Default,,0000,0000,0000,,interact with the shell implemented in a lot Dialogue: 0,0:22:35.70,0:22:39.71,Default,,0000,0000,0000,,of different languages. So for\Nexample, let's see here a Dialogue: 0,0:22:39.71,0:22:43.14,Default,,0000,0000,0000,,Python script that has a magic line at the Dialogue: 0,0:22:43.14,0:22:45.54,Default,,0000,0000,0000,,beginning that I'm not explaining for now. Dialogue: 0,0:22:45.54,0:22:48.33,Default,,0000,0000,0000,,Then we have "import sys", Dialogue: 0,0:22:48.33,0:22:53.63,Default,,0000,0000,0000,,it's kind of like... Python is not,\Nby default, trying to interact Dialogue: 0,0:22:53.63,0:22:56.100,Default,,0000,0000,0000,,with the shell so you will have to import Dialogue: 0,0:22:56.100,0:22:58.80,Default,,0000,0000,0000,,some library. And then we're doing a Dialogue: 0,0:22:58.80,0:23:01.53,Default,,0000,0000,0000,,really silly thing of just iterating Dialogue: 0,0:23:01.53,0:23:06.44,Default,,0000,0000,0000,,over "sys.argv[1:]". Dialogue: 0,0:23:06.44,0:23:12.81,Default,,0000,0000,0000,,"sys.argv" is kind of similar to what\Nin bash we're getting as $0, $1, &c. Dialogue: 0,0:23:12.81,0:23:16.65,Default,,0000,0000,0000,,Like the vector of the arguments, we're\Nprinting it in the reversed order. Dialogue: 0,0:23:16.65,0:23:21.18,Default,,0000,0000,0000,,And the magic line at the beginning is Dialogue: 0,0:23:21.18,0:23:23.100,Default,,0000,0000,0000,,called a shebang and is the way that the Dialogue: 0,0:23:23.100,0:23:26.16,Default,,0000,0000,0000,,shell will know how to run this program. Dialogue: 0,0:23:26.16,0:23:30.51,Default,,0000,0000,0000,,You can always do something like Dialogue: 0,0:23:30.51,0:23:34.38,Default,,0000,0000,0000,,"python script.py", and then "a b c" and that Dialogue: 0,0:23:34.38,0:23:36.66,Default,,0000,0000,0000,,will work, always, like that. But Dialogue: 0,0:23:36.66,0:23:39.12,Default,,0000,0000,0000,,what if we want to make this to be Dialogue: 0,0:23:39.12,0:23:41.31,Default,,0000,0000,0000,,executable from the shell? The way the Dialogue: 0,0:23:41.31,0:23:44.19,Default,,0000,0000,0000,,shell knows that it has to use python as the Dialogue: 0,0:23:44.19,0:23:48.45,Default,,0000,0000,0000,,interpreter to run this file is using Dialogue: 0,0:23:48.45,0:23:52.44,Default,,0000,0000,0000,,that first line. And that first line is Dialogue: 0,0:23:52.44,0:23:56.62,Default,,0000,0000,0000,,giving it the path to where that thing lives. Dialogue: 0,0:23:58.50,0:23:59.60,Default,,0000,0000,0000,,However, you might not know. Dialogue: 0,0:23:59.61,0:24:01.83,Default,,0000,0000,0000,,Like, different machines will have probably Dialogue: 0,0:24:01.83,0:24:04.05,Default,,0000,0000,0000,,different places where they put python Dialogue: 0,0:24:04.05,0:24:06.09,Default,,0000,0000,0000,,and you might not want to assume where Dialogue: 0,0:24:06.09,0:24:08.79,Default,,0000,0000,0000,,python is installed, or any other interpreter. Dialogue: 0,0:24:08.79,0:24:16.38,Default,,0000,0000,0000,,So one thing that you can do is use the Dialogue: 0,0:24:16.38,0:24:17.72,Default,,0000,0000,0000,,"env" command. Dialogue: 0,0:24:18.28,0:24:21.56,Default,,0000,0000,0000,,You can also give arguments in the shebang, so Dialogue: 0,0:24:21.57,0:24:23.94,Default,,0000,0000,0000,,what we're doing here is specifying Dialogue: 0,0:24:23.94,0:24:29.72,Default,,0000,0000,0000,,run the "env" command, that is for pretty much every\Nsystem, there are some exceptions, but like for Dialogue: 0,0:24:29.72,0:24:31.55,Default,,0000,0000,0000,,pretty much every system it's is in Dialogue: 0,0:24:31.55,0:24:33.62,Default,,0000,0000,0000,,"usr/bin", where a lot of binaries live, Dialogue: 0,0:24:33.62,0:24:36.20,Default,,0000,0000,0000,,and then we're calling it with the Dialogue: 0,0:24:36.20,0:24:38.57,Default,,0000,0000,0000,,argument "python". And then that will make Dialogue: 0,0:24:38.57,0:24:42.02,Default,,0000,0000,0000,,use of the path environment variable Dialogue: 0,0:24:42.02,0:24:43.58,Default,,0000,0000,0000,,that we saw in the first lecture. It's Dialogue: 0,0:24:43.58,0:24:45.68,Default,,0000,0000,0000,,gonna search in that path for the Python Dialogue: 0,0:24:45.68,0:24:48.62,Default,,0000,0000,0000,,binary and then it's gonna use that to Dialogue: 0,0:24:48.62,0:24:50.48,Default,,0000,0000,0000,,interpret this file. And that will make Dialogue: 0,0:24:50.48,0:24:52.49,Default,,0000,0000,0000,,this more portable so it can be run in Dialogue: 0,0:24:52.49,0:24:57.52,Default,,0000,0000,0000,,my machine, and your machine\Nand some other machine. Dialogue: 0,0:25:08.02,0:25:12.14,Default,,0000,0000,0000,,Another thing is that the bash is not Dialogue: 0,0:25:12.14,0:25:14.30,Default,,0000,0000,0000,,really like modern, it was Dialogue: 0,0:25:14.30,0:25:16.34,Default,,0000,0000,0000,,developed a while ago. And sometimes Dialogue: 0,0:25:16.34,0:25:18.89,Default,,0000,0000,0000,,it can be tricky to debug. By Dialogue: 0,0:25:18.89,0:25:21.98,Default,,0000,0000,0000,,default, and the ways it will fail Dialogue: 0,0:25:21.98,0:25:24.02,Default,,0000,0000,0000,,sometimes are intuitive like the way we Dialogue: 0,0:25:24.02,0:25:26.18,Default,,0000,0000,0000,,saw before of like foo command not Dialogue: 0,0:25:26.18,0:25:28.61,Default,,0000,0000,0000,,existing, sometimes it's not. So there's Dialogue: 0,0:25:28.61,0:25:31.28,Default,,0000,0000,0000,,like a really nifty tool that we have Dialogue: 0,0:25:31.28,0:25:34.31,Default,,0000,0000,0000,,linked in the lecture notes, which is called Dialogue: 0,0:25:34.31,0:25:37.58,Default,,0000,0000,0000,,"shellcheck", that will kind of give you Dialogue: 0,0:25:37.58,0:25:40.01,Default,,0000,0000,0000,,both warnings and syntactic errors Dialogue: 0,0:25:40.01,0:25:43.25,Default,,0000,0000,0000,,and other things that you might\Nnot have quoted properly, Dialogue: 0,0:25:43.25,0:25:46.04,Default,,0000,0000,0000,,or you might have misplaced spaces in Dialogue: 0,0:25:46.04,0:25:50.06,Default,,0000,0000,0000,,your files. So for example for\Nextremely simple "mcd.sh" Dialogue: 0,0:25:50.06,0:25:51.98,Default,,0000,0000,0000,,file we're getting a couple Dialogue: 0,0:25:51.98,0:25:54.80,Default,,0000,0000,0000,,of errors saying hey, surprisingly, Dialogue: 0,0:25:54.80,0:25:56.09,Default,,0000,0000,0000,,we're missing a shebang, like this Dialogue: 0,0:25:56.09,0:25:59.06,Default,,0000,0000,0000,,might not interpret it correctly if you're Dialogue: 0,0:25:59.06,0:26:02.00,Default,,0000,0000,0000,,it at a different system. Also, this Dialogue: 0,0:26:02.00,0:26:05.62,Default,,0000,0000,0000,,CD is taking a command and it might not Dialogue: 0,0:26:05.62,0:26:08.96,Default,,0000,0000,0000,,expand properly so instead of using CD Dialogue: 0,0:26:08.96,0:26:11.30,Default,,0000,0000,0000,,you might want to use something like CD Dialogue: 0,0:26:11.30,0:26:14.54,Default,,0000,0000,0000,,and then an OR and then an "exit". We go Dialogue: 0,0:26:14.54,0:26:16.49,Default,,0000,0000,0000,,back to what we explained earlier, what Dialogue: 0,0:26:16.49,0:26:18.92,Default,,0000,0000,0000,,this will do is like if the Dialogue: 0,0:26:18.92,0:26:21.86,Default,,0000,0000,0000,,CD doesn't end correctly, you cannot CD Dialogue: 0,0:26:21.86,0:26:23.72,Default,,0000,0000,0000,,into the folder because either you Dialogue: 0,0:26:23.72,0:26:25.25,Default,,0000,0000,0000,,don't have permissions, it doesn't exist... Dialogue: 0,0:26:25.25,0:26:28.78,Default,,0000,0000,0000,,That will give a nonzero error Dialogue: 0,0:26:28.78,0:26:32.42,Default,,0000,0000,0000,,command, so you will execute exit Dialogue: 0,0:26:32.42,0:26:33.92,Default,,0000,0000,0000,,and that will stop the script Dialogue: 0,0:26:33.92,0:26:35.81,Default,,0000,0000,0000,,instead of continue executing as if Dialogue: 0,0:26:35.81,0:26:37.24,Default,,0000,0000,0000,,you were in a place that you are Dialogue: 0,0:26:37.24,0:26:42.90,Default,,0000,0000,0000,,actually not in. And actually\NI haven't tested, but I Dialogue: 0,0:26:42.92,0:26:47.18,Default,,0000,0000,0000,,think we can check for "example.sh" Dialogue: 0,0:26:47.18,0:26:50.81,Default,,0000,0000,0000,,and here we're getting that we should be Dialogue: 0,0:26:50.81,0:26:55.07,Default,,0000,0000,0000,,checking the exit code in a\Ndifferent way, because it's Dialogue: 0,0:26:55.07,0:26:57.71,Default,,0000,0000,0000,,probably not the best way, doing it this Dialogue: 0,0:26:57.71,0:27:01.58,Default,,0000,0000,0000,,way. One last remark I want to make Dialogue: 0,0:27:01.58,0:27:05.09,Default,,0000,0000,0000,,is that when you're writing bash scripts Dialogue: 0,0:27:05.09,0:27:07.16,Default,,0000,0000,0000,,or functions for that matter, Dialogue: 0,0:27:07.16,0:27:09.08,Default,,0000,0000,0000,,there's kind of a difference between Dialogue: 0,0:27:09.08,0:27:12.59,Default,,0000,0000,0000,,writing bash scripts in isolation like a Dialogue: 0,0:27:12.59,0:27:14.15,Default,,0000,0000,0000,,thing that you're gonna run, and a thing Dialogue: 0,0:27:14.15,0:27:16.10,Default,,0000,0000,0000,,that you're gonna load into your shell. Dialogue: 0,0:27:16.10,0:27:19.85,Default,,0000,0000,0000,,We will see some of this in the command Dialogue: 0,0:27:19.85,0:27:23.09,Default,,0000,0000,0000,,line environment lecture, where we will kind of Dialogue: 0,0:27:23.09,0:27:29.06,Default,,0000,0000,0000,,be tooling with the bashrc and the\Nsshrc. But in general, if you make Dialogue: 0,0:27:29.06,0:27:31.37,Default,,0000,0000,0000,,changes to for example where you are, Dialogue: 0,0:27:31.37,0:27:34.01,Default,,0000,0000,0000,,like if you CD into a bash script and you Dialogue: 0,0:27:34.01,0:27:36.92,Default,,0000,0000,0000,,just execute that bash script, it won't CD Dialogue: 0,0:27:36.92,0:27:39.98,Default,,0000,0000,0000,,into the shell are right now. But if you Dialogue: 0,0:27:39.98,0:27:42.98,Default,,0000,0000,0000,,have loaded the code directly into Dialogue: 0,0:27:42.98,0:27:45.56,Default,,0000,0000,0000,,your shell, for example you load... Dialogue: 0,0:27:45.56,0:27:48.44,Default,,0000,0000,0000,,you source the function and then you execute Dialogue: 0,0:27:48.44,0:27:50.27,Default,,0000,0000,0000,,the function then you will get those Dialogue: 0,0:27:50.27,0:27:52.00,Default,,0000,0000,0000,,side effects. And the same goes for Dialogue: 0,0:27:52.00,0:27:57.22,Default,,0000,0000,0000,,defining variables into the shell. Dialogue: 0,0:27:57.22,0:28:03.95,Default,,0000,0000,0000,,Now I'm going to talk about some\Ntools that I think are nifty when Dialogue: 0,0:28:03.95,0:28:07.58,Default,,0000,0000,0000,,working with the shell. The first was Dialogue: 0,0:28:07.58,0:28:09.80,Default,,0000,0000,0000,,also briefly introduced yesterday. Dialogue: 0,0:28:09.80,0:28:13.31,Default,,0000,0000,0000,,How do you know what flags, or like Dialogue: 0,0:28:13.31,0:28:15.32,Default,,0000,0000,0000,,what exact commands are. Like how I am Dialogue: 0,0:28:15.32,0:28:21.89,Default,,0000,0000,0000,,supposed to know that LS minus L will list\Nthe files in a list format, or that Dialogue: 0,0:28:21.89,0:28:25.79,Default,,0000,0000,0000,,if I do "move - i", it's gonna like prom me Dialogue: 0,0:28:25.79,0:28:28.64,Default,,0000,0000,0000,,for stuff. For that what you have is the "man" Dialogue: 0,0:28:28.64,0:28:30.73,Default,,0000,0000,0000,,command. And the man command will kind of Dialogue: 0,0:28:30.73,0:28:33.59,Default,,0000,0000,0000,,have like a lot of information of how Dialogue: 0,0:28:33.59,0:28:35.81,Default,,0000,0000,0000,,will you go about... so for example here it Dialogue: 0,0:28:35.81,0:28:40.34,Default,,0000,0000,0000,,will explain for the "-i" flag, there are Dialogue: 0,0:28:40.34,0:28:43.97,Default,,0000,0000,0000,,all these options you can do. That's Dialogue: 0,0:28:43.97,0:28:45.62,Default,,0000,0000,0000,,actually pretty useful and it will work Dialogue: 0,0:28:45.62,0:28:51.54,Default,,0000,0000,0000,,not only for really simple commands\Nthat come packaged with your OS Dialogue: 0,0:28:51.54,0:28:55.81,Default,,0000,0000,0000,,but will also work with some tools\Nthat you install from the internet Dialogue: 0,0:28:55.81,0:28:58.24,Default,,0000,0000,0000,,for example, if the person that did the Dialogue: 0,0:28:58.24,0:29:01.39,Default,,0000,0000,0000,,installation made it so that the man Dialogue: 0,0:29:01.39,0:29:03.40,Default,,0000,0000,0000,,package were also installed. So for example Dialogue: 0,0:29:03.40,0:29:06.49,Default,,0000,0000,0000,,a tool that we're gonna cover in a bit Dialogue: 0,0:29:06.49,0:29:12.37,Default,,0000,0000,0000,,which is called "ripgrep" and\Nis called with RG, this didn't Dialogue: 0,0:29:12.37,0:29:14.98,Default,,0000,0000,0000,,come with my system but it has installed Dialogue: 0,0:29:14.98,0:29:17.23,Default,,0000,0000,0000,,its own man page and I have it here and Dialogue: 0,0:29:17.23,0:29:21.70,Default,,0000,0000,0000,,I can access it. For some commands the Dialogue: 0,0:29:21.70,0:29:25.03,Default,,0000,0000,0000,,man page is useful but sometimes it can be Dialogue: 0,0:29:25.03,0:29:28.27,Default,,0000,0000,0000,,tricky to decipher because it's more Dialogue: 0,0:29:28.27,0:29:30.40,Default,,0000,0000,0000,,kind of a documentation and a Dialogue: 0,0:29:30.40,0:29:32.68,Default,,0000,0000,0000,,description of all the things the tool Dialogue: 0,0:29:32.68,0:29:35.86,Default,,0000,0000,0000,,can do. Sometimes it will have Dialogue: 0,0:29:35.86,0:29:37.72,Default,,0000,0000,0000,,examples but sometimes not, and sometimes Dialogue: 0,0:29:37.72,0:29:41.62,Default,,0000,0000,0000,,the tool can do a lot of things so a Dialogue: 0,0:29:41.62,0:29:45.25,Default,,0000,0000,0000,,couple of good tools that I use commonly Dialogue: 0,0:29:45.25,0:29:50.29,Default,,0000,0000,0000,,are "convert" or "ffmpeg", which deal\Nwith images and video respectively and Dialogue: 0,0:29:50.29,0:29:52.42,Default,,0000,0000,0000,,the man pages are like enormous. So there's Dialogue: 0,0:29:52.42,0:29:54.85,Default,,0000,0000,0000,,one neat tool called "tldr" that Dialogue: 0,0:29:54.85,0:29:58.24,Default,,0000,0000,0000,,you can install and you will have like Dialogue: 0,0:29:58.24,0:30:02.71,Default,,0000,0000,0000,,some nice kind of explanatory examples Dialogue: 0,0:30:02.71,0:30:05.47,Default,,0000,0000,0000,,of how you want to use this command. And you Dialogue: 0,0:30:05.47,0:30:07.84,Default,,0000,0000,0000,,can always Google for this, but I find Dialogue: 0,0:30:07.84,0:30:10.12,Default,,0000,0000,0000,,myself saving going into the Dialogue: 0,0:30:10.12,0:30:12.64,Default,,0000,0000,0000,,browser, looking about some examples and Dialogue: 0,0:30:12.64,0:30:14.92,Default,,0000,0000,0000,,coming back, whereas "tldr" are Dialogue: 0,0:30:14.92,0:30:16.87,Default,,0000,0000,0000,,community contributed and Dialogue: 0,0:30:16.87,0:30:19.21,Default,,0000,0000,0000,,they're fairly useful. Then, Dialogue: 0,0:30:19.21,0:30:23.02,Default,,0000,0000,0000,,the one for "ffmpeg" has a lot of Dialogue: 0,0:30:23.02,0:30:24.94,Default,,0000,0000,0000,,useful examples that are more nicely Dialogue: 0,0:30:24.94,0:30:26.80,Default,,0000,0000,0000,,formatted (if you don't have a huge Dialogue: 0,0:30:26.80,0:30:30.82,Default,,0000,0000,0000,,font size for recording). Or even Dialogue: 0,0:30:30.82,0:30:33.25,Default,,0000,0000,0000,,simple commands like "tar", that have a lot Dialogue: 0,0:30:33.25,0:30:35.47,Default,,0000,0000,0000,,of options that you are combining. So for Dialogue: 0,0:30:35.47,0:30:37.84,Default,,0000,0000,0000,,example, here you can be combining 2, 3... Dialogue: 0,0:30:37.84,0:30:41.71,Default,,0000,0000,0000,,different flags and it can not be Dialogue: 0,0:30:41.71,0:30:43.42,Default,,0000,0000,0000,,obvious, when you want to combine Dialogue: 0,0:30:43.42,0:30:48.43,Default,,0000,0000,0000,,different ones. That's how you Dialogue: 0,0:30:48.43,0:30:54.85,Default,,0000,0000,0000,,would go about finding more about these tools.\NOn the topic of finding, let's try Dialogue: 0,0:30:54.85,0:30:58.69,Default,,0000,0000,0000,,learning how to find files. You can Dialogue: 0,0:30:58.69,0:31:03.10,Default,,0000,0000,0000,,always go "ls", and like you can go like Dialogue: 0,0:31:03.10,0:31:05.95,Default,,0000,0000,0000,,"ls project1", and Dialogue: 0,0:31:05.95,0:31:08.56,Default,,0000,0000,0000,,keep LS'ing all the way through. But Dialogue: 0,0:31:08.56,0:31:11.74,Default,,0000,0000,0000,,maybe, if we already know that we want Dialogue: 0,0:31:11.74,0:31:15.45,Default,,0000,0000,0000,,to look for all the folders called Dialogue: 0,0:31:15.45,0:31:19.00,Default,,0000,0000,0000,,"src", then there's probably a better command Dialogue: 0,0:31:19.00,0:31:21.40,Default,,0000,0000,0000,,for doing that. And that's "find". Dialogue: 0,0:31:21.46,0:31:26.68,Default,,0000,0000,0000,,Find is the tool that, pretty much comes\Nwith every UNIX system. And find, Dialogue: 0,0:31:26.68,0:31:35.23,Default,,0000,0000,0000,,we're gonna give it... here we're\Nsaying we want to call find in the Dialogue: 0,0:31:35.23,0:31:37.51,Default,,0000,0000,0000,,current folder, remember that "." stands Dialogue: 0,0:31:37.51,0:31:40.15,Default,,0000,0000,0000,,for the current folder, and we want the Dialogue: 0,0:31:40.15,0:31:46.54,Default,,0000,0000,0000,,name to be "src" and we want the type to\Nbe a directory. And by typing that it's Dialogue: 0,0:31:46.54,0:31:49.87,Default,,0000,0000,0000,,gonna recursively go through the current Dialogue: 0,0:31:49.87,0:31:52.33,Default,,0000,0000,0000,,directory and look for all these files, Dialogue: 0,0:31:52.33,0:31:58.66,Default,,0000,0000,0000,,or folders in this case, that match this\Npattern. Find has a lot of useful Dialogue: 0,0:31:58.66,0:32:01.84,Default,,0000,0000,0000,,flags. So for example, you can even test Dialogue: 0,0:32:01.84,0:32:05.44,Default,,0000,0000,0000,,for the path to be in a way. Here we're Dialogue: 0,0:32:05.44,0:32:08.23,Default,,0000,0000,0000,,saying we want some number of folders, Dialogue: 0,0:32:08.23,0:32:09.91,Default,,0000,0000,0000,,we don't really care how many folders, Dialogue: 0,0:32:09.91,0:32:13.18,Default,,0000,0000,0000,,and then we care about all the Python Dialogue: 0,0:32:13.18,0:32:17.83,Default,,0000,0000,0000,,scripts, all the things with the extension\N".py", that are within a Dialogue: 0,0:32:17.83,0:32:19.90,Default,,0000,0000,0000,,test folder. And we're also checking, just in Dialogue: 0,0:32:19.90,0:32:21.52,Default,,0000,0000,0000,,cases really but we're checking just Dialogue: 0,0:32:21.52,0:32:24.46,Default,,0000,0000,0000,,that it's also a type F, which stands for Dialogue: 0,0:32:24.46,0:32:28.71,Default,,0000,0000,0000,,file. We're getting all these files. Dialogue: 0,0:32:28.71,0:32:32.17,Default,,0000,0000,0000,,You can also use different flags for things Dialogue: 0,0:32:32.17,0:32:34.00,Default,,0000,0000,0000,,that are not the path or the name. Dialogue: 0,0:32:34.00,0:32:38.16,Default,,0000,0000,0000,,You could check things that have been Dialogue: 0,0:32:38.16,0:32:42.06,Default,,0000,0000,0000,,modified ("-mtime" is for the modification\Ntime), things that have been Dialogue: 0,0:32:42.07,0:32:44.54,Default,,0000,0000,0000,,modified in the last day, which is gonna Dialogue: 0,0:32:44.56,0:32:46.66,Default,,0000,0000,0000,,be pretty much everything. So this is gonna print Dialogue: 0,0:32:46.66,0:32:49.03,Default,,0000,0000,0000,,a lot of the files we created and files Dialogue: 0,0:32:49.03,0:32:51.85,Default,,0000,0000,0000,,that were already there. You can even Dialogue: 0,0:32:51.85,0:32:54.96,Default,,0000,0000,0000,,use other things like size, the owner, Dialogue: 0,0:32:54.96,0:32:59.08,Default,,0000,0000,0000,,permissions, you name it. What is even more Dialogue: 0,0:32:59.08,0:33:01.87,Default,,0000,0000,0000,,powerful is, "find" can find stuff Dialogue: 0,0:33:01.87,0:33:04.27,Default,,0000,0000,0000,,but it also can do stuff when you Dialogue: 0,0:33:04.27,0:33:10.69,Default,,0000,0000,0000,,find those files. So we could look for all Dialogue: 0,0:33:10.69,0:33:14.08,Default,,0000,0000,0000,,the files that have a TMP Dialogue: 0,0:33:14.08,0:33:18.16,Default,,0000,0000,0000,,extension, which is a temporary extension, and Dialogue: 0,0:33:18.16,0:33:22.72,Default,,0000,0000,0000,,then, we can tell "find" that\Nfor every one of those files, Dialogue: 0,0:33:22.72,0:33:26.35,Default,,0000,0000,0000,,just execute the "rm" command for them. And Dialogue: 0,0:33:26.35,0:33:29.05,Default,,0000,0000,0000,,that will just be calling "rm" with all Dialogue: 0,0:33:29.05,0:33:32.35,Default,,0000,0000,0000,,these files. So let's first execute it Dialogue: 0,0:33:32.35,0:33:35.76,Default,,0000,0000,0000,,without, and then we execute it with it. Dialogue: 0,0:33:35.76,0:33:38.95,Default,,0000,0000,0000,,Again, as with the command line Dialogue: 0,0:33:38.95,0:33:41.47,Default,,0000,0000,0000,,philosophy, it looks like nothing Dialogue: 0,0:33:41.47,0:33:48.07,Default,,0000,0000,0000,,happened. But since we have\Na zero error code, something Dialogue: 0,0:33:48.07,0:33:49.54,Default,,0000,0000,0000,,happened - just that everything went Dialogue: 0,0:33:49.54,0:33:51.49,Default,,0000,0000,0000,,correct and everything is fine. And now, Dialogue: 0,0:33:51.49,0:33:57.81,Default,,0000,0000,0000,,if we look for these files,\Nthey aren't there anymore. Dialogue: 0,0:33:57.81,0:34:02.95,Default,,0000,0000,0000,,Another nice thing about the shell\Nin general is that there are Dialogue: 0,0:34:02.95,0:34:05.89,Default,,0000,0000,0000,,these tools, but people will keep Dialogue: 0,0:34:05.89,0:34:08.23,Default,,0000,0000,0000,,finding new ways, so alternative Dialogue: 0,0:34:08.23,0:34:12.22,Default,,0000,0000,0000,,ways of writing these tools. It's\Nnice to know about it. So, for Dialogue: 0,0:34:12.22,0:34:20.02,Default,,0000,0000,0000,,example find if you just want to match\Nthe things that end in "tmp" Dialogue: 0,0:34:20.02,0:34:24.19,Default,,0000,0000,0000,,it can be sometimes weird to do this\Nthing, it has a long command. Dialogue: 0,0:34:24.19,0:34:27.76,Default,,0000,0000,0000,,There's things like "fd", Dialogue: 0,0:34:27.76,0:34:32.32,Default,,0000,0000,0000,,for example, that is a shorter command\Nthat by default will use regex Dialogue: 0,0:34:32.32,0:34:34.90,Default,,0000,0000,0000,,and will ignore your gitfiles, so you Dialogue: 0,0:34:34.90,0:34:38.02,Default,,0000,0000,0000,,don't even search for them. It Dialogue: 0,0:34:38.02,0:34:42.88,Default,,0000,0000,0000,,will color-code, it will have better\NUnicode support... It's nice to Dialogue: 0,0:34:42.88,0:34:45.04,Default,,0000,0000,0000,,know about some of these tools. But, again, Dialogue: 0,0:34:45.04,0:34:52.15,Default,,0000,0000,0000,,the main idea is that if you are aware\Nthat these tools exist, you can Dialogue: 0,0:34:52.15,0:34:53.74,Default,,0000,0000,0000,,save yourself a lot of time from doing Dialogue: 0,0:34:53.74,0:34:57.66,Default,,0000,0000,0000,,kind of menial and repetitive tasks. Dialogue: 0,0:34:57.66,0:35:00.01,Default,,0000,0000,0000,,Another command to bear in mind is like Dialogue: 0,0:35:00.01,0:35:01.99,Default,,0000,0000,0000,,"find". Some of you may be Dialogue: 0,0:35:01.99,0:35:04.30,Default,,0000,0000,0000,,wondering, "find" is probably just Dialogue: 0,0:35:04.30,0:35:06.52,Default,,0000,0000,0000,,actually going through a directory Dialogue: 0,0:35:06.52,0:35:09.58,Default,,0000,0000,0000,,structure and looking for things but Dialogue: 0,0:35:09.58,0:35:11.26,Default,,0000,0000,0000,,what if I'm doing a lot of "finds" a day? Dialogue: 0,0:35:11.26,0:35:12.85,Default,,0000,0000,0000,,Wouldn't it be better, doing kind of Dialogue: 0,0:35:12.85,0:35:18.79,Default,,0000,0000,0000,,a database approach and build an index\Nfirst, and then use that index Dialogue: 0,0:35:18.79,0:35:21.52,Default,,0000,0000,0000,,and update it in some way. Well, actually Dialogue: 0,0:35:21.52,0:35:23.38,Default,,0000,0000,0000,,most Unix systems already do it and Dialogue: 0,0:35:23.38,0:35:28.17,Default,,0000,0000,0000,,this is through the "locate" command and Dialogue: 0,0:35:28.17,0:35:31.69,Default,,0000,0000,0000,,the way that the locate will Dialogue: 0,0:35:31.69,0:35:35.47,Default,,0000,0000,0000,,be used... it will just look for paths in Dialogue: 0,0:35:35.47,0:35:38.68,Default,,0000,0000,0000,,your file system that have the substring Dialogue: 0,0:35:38.68,0:35:44.71,Default,,0000,0000,0000,,that you want. I actually don't know if it\Nwill work... Okay, it worked. Let me try to Dialogue: 0,0:35:44.71,0:35:49.84,Default,,0000,0000,0000,,do something like "missing-semester". Dialogue: 0,0:35:51.84,0:35:53.95,Default,,0000,0000,0000,,You're gonna take a while but Dialogue: 0,0:35:53.95,0:35:56.11,Default,,0000,0000,0000,,it found all these files that are somewhere Dialogue: 0,0:35:56.11,0:35:57.73,Default,,0000,0000,0000,,in my file system and since it has Dialogue: 0,0:35:57.73,0:36:01.75,Default,,0000,0000,0000,,built an index already on them, it's much Dialogue: 0,0:36:01.75,0:36:05.68,Default,,0000,0000,0000,,faster. And then, to keep it updated, Dialogue: 0,0:36:05.68,0:36:11.98,Default,,0000,0000,0000,,using the "updatedb" command\Nthat is running through cron, Dialogue: 0,0:36:13.84,0:36:18.49,Default,,0000,0000,0000,,to update this database. Finding files, again, is Dialogue: 0,0:36:18.49,0:36:23.23,Default,,0000,0000,0000,,really useful. Sometimes you're actually concerned\Nabout, not the files themselves, Dialogue: 0,0:36:23.23,0:36:26.74,Default,,0000,0000,0000,,but the content of the files. For that Dialogue: 0,0:36:26.74,0:36:31.42,Default,,0000,0000,0000,,you can use the grep command that we Dialogue: 0,0:36:31.42,0:36:33.88,Default,,0000,0000,0000,,have seen so far. So you could do Dialogue: 0,0:36:33.88,0:36:37.74,Default,,0000,0000,0000,,something like grep foobar in MCD, it's there. Dialogue: 0,0:36:37.74,0:36:43.69,Default,,0000,0000,0000,,What if you want to, again, recursively\Nsearch through the current Dialogue: 0,0:36:43.69,0:36:45.76,Default,,0000,0000,0000,,structure and look for more files, right? Dialogue: 0,0:36:45.76,0:36:48.70,Default,,0000,0000,0000,,We don't want to do this manually. Dialogue: 0,0:36:48.70,0:36:51.22,Default,,0000,0000,0000,,We could use "find", and the "-exec", but Dialogue: 0,0:36:51.22,0:36:58.92,Default,,0000,0000,0000,,actually "grep" has the "-R" flag\Nthat will go through the entire Dialogue: 0,0:36:58.92,0:37:03.61,Default,,0000,0000,0000,,directory, here. And it's telling us Dialogue: 0,0:37:03.61,0:37:06.58,Default,,0000,0000,0000,,that oh we have the foobar line in example.sh Dialogue: 0,0:37:06.58,0:37:09.28,Default,,0000,0000,0000,,at these three places and in Dialogue: 0,0:37:09.28,0:37:14.59,Default,,0000,0000,0000,,this other two places in foobar. This can be Dialogue: 0,0:37:14.59,0:37:16.90,Default,,0000,0000,0000,,really convenient. Mainly, the Dialogue: 0,0:37:16.90,0:37:18.94,Default,,0000,0000,0000,,use case for this is you know you have Dialogue: 0,0:37:18.94,0:37:21.91,Default,,0000,0000,0000,,written some code in some programming Dialogue: 0,0:37:21.91,0:37:23.86,Default,,0000,0000,0000,,language, and you know it's somewhere in Dialogue: 0,0:37:23.86,0:37:26.20,Default,,0000,0000,0000,,your file system but you actually don't Dialogue: 0,0:37:26.20,0:37:28.60,Default,,0000,0000,0000,,know. But you can actually quickly search. Dialogue: 0,0:37:28.60,0:37:32.98,Default,,0000,0000,0000,,So for example, I can quickly search Dialogue: 0,0:37:35.66,0:37:40.32,Default,,0000,0000,0000,,for all the Python files that I have in my Dialogue: 0,0:37:40.33,0:37:45.46,Default,,0000,0000,0000,,scratch folder where I used the request library. Dialogue: 0,0:37:45.46,0:37:47.59,Default,,0000,0000,0000,,And if I run this, it's giving me Dialogue: 0,0:37:47.59,0:37:50.89,Default,,0000,0000,0000,,through all these files, exactly in Dialogue: 0,0:37:50.89,0:37:53.65,Default,,0000,0000,0000,,what line it has been found. And here Dialogue: 0,0:37:53.65,0:37:56.26,Default,,0000,0000,0000,,instead of using grep, which is fine, Dialogue: 0,0:37:56.26,0:37:58.93,Default,,0000,0000,0000,,you could also do this, I'm using "ripgrep", Dialogue: 0,0:37:58.93,0:38:05.26,Default,,0000,0000,0000,,which is kind of the same idea but\Nagain trying to bring some more Dialogue: 0,0:38:05.26,0:38:09.73,Default,,0000,0000,0000,,niceties like color coding or file Dialogue: 0,0:38:09.73,0:38:16.48,Default,,0000,0000,0000,,processing and other things. It think it has,\Nalso, unicode support. It's also pretty Dialogue: 0,0:38:16.48,0:38:22.83,Default,,0000,0000,0000,,fast so you are not paying like a\Ntrade-off on this being slower and Dialogue: 0,0:38:22.83,0:38:25.42,Default,,0000,0000,0000,,there's a lot of useful flags. You Dialogue: 0,0:38:25.42,0:38:27.67,Default,,0000,0000,0000,,can say, oh, I actually want to get some Dialogue: 0,0:38:27.67,0:38:30.46,Default,,0000,0000,0000,,context around those results. Dialogue: 0,0:38:33.04,0:38:36.40,Default,,0000,0000,0000,,So I want to get like five\Nlines of context around Dialogue: 0,0:38:36.40,0:38:42.82,Default,,0000,0000,0000,,that, so you can see where that import\Nlives and see code around it. Dialogue: 0,0:38:42.82,0:38:44.17,Default,,0000,0000,0000,,Here in the import it's not really useful Dialogue: 0,0:38:44.17,0:38:45.82,Default,,0000,0000,0000,,but like if you're looking for where you Dialogue: 0,0:38:45.82,0:38:49.72,Default,,0000,0000,0000,,use the function, for example, it will Dialogue: 0,0:38:49.72,0:38:54.01,Default,,0000,0000,0000,,be very handy. We can also do things like Dialogue: 0,0:38:54.01,0:38:59.17,Default,,0000,0000,0000,,we can search, for example here,. Dialogue: 0,0:38:59.17,0:39:04.84,Default,,0000,0000,0000,,A more advanced use, we can say, Dialogue: 0,0:39:04.84,0:39:11.58,Default,,0000,0000,0000,,"-u" is for don't ignore hidden files, sometimes Dialogue: 0,0:39:12.52,0:39:16.36,Default,,0000,0000,0000,,you want to be ignoring hidden\Nfiles, except if you want to Dialogue: 0,0:39:16.36,0:39:23.50,Default,,0000,0000,0000,,search config files, that are by default\Nhidden. Then, instead of printing Dialogue: 0,0:39:23.50,0:39:28.40,Default,,0000,0000,0000,,the matches, we're asking to do something\Nthat would be kind of hard, I think, Dialogue: 0,0:39:28.40,0:39:31.38,Default,,0000,0000,0000,,to do with grep, out of my head, which is Dialogue: 0,0:39:31.39,0:39:34.57,Default,,0000,0000,0000,,"I want you to print all the files that Dialogue: 0,0:39:34.57,0:39:37.75,Default,,0000,0000,0000,,don't match the pattern I'm giving you", which Dialogue: 0,0:39:37.75,0:39:40.03,Default,,0000,0000,0000,,may be a weird thing to ask here but Dialogue: 0,0:39:40.03,0:39:42.94,Default,,0000,0000,0000,,then we keep going... And this pattern here Dialogue: 0,0:39:42.94,0:39:45.79,Default,,0000,0000,0000,,is a small regex which is saying Dialogue: 0,0:39:45.79,0:39:48.10,Default,,0000,0000,0000,,at the beginning of the line I have a Dialogue: 0,0:39:48.10,0:39:51.19,Default,,0000,0000,0000,,"#" and a "!", and that's a shebang. Dialogue: 0,0:39:51.19,0:39:53.47,Default,,0000,0000,0000,,Like that, we're searching here for all Dialogue: 0,0:39:53.47,0:39:56.65,Default,,0000,0000,0000,,the files that don't have a shebang Dialogue: 0,0:39:56.65,0:39:59.37,Default,,0000,0000,0000,,and then we're giving it, here, Dialogue: 0,0:39:59.37,0:40:02.47,Default,,0000,0000,0000,,a "-t sh" to only look for "sh" Dialogue: 0,0:40:02.47,0:40:07.66,Default,,0000,0000,0000,,files, because maybe all your\NPython or text files are fine Dialogue: 0,0:40:07.66,0:40:10.00,Default,,0000,0000,0000,,without a shebang. And here it's telling us Dialogue: 0,0:40:10.00,0:40:13.02,Default,,0000,0000,0000,,"oh, MCD is obviously missing a shebang" Dialogue: 0,0:40:14.76,0:40:16.66,Default,,0000,0000,0000,,We can even... It has like some Dialogue: 0,0:40:16.66,0:40:19.12,Default,,0000,0000,0000,,nice flags, so for example if we Dialogue: 0,0:40:19.12,0:40:21.36,Default,,0000,0000,0000,,include the "stats" flag Dialogue: 0,0:40:28.70,0:40:34.12,Default,,0000,0000,0000,,it will get all these results but it will\Nalso tell us information about all Dialogue: 0,0:40:34.12,0:40:35.41,Default,,0000,0000,0000,,the things that it searched. For example, Dialogue: 0,0:40:35.41,0:40:40.39,Default,,0000,0000,0000,,the number of matches that it found,\Nthe lines, the file searched, Dialogue: 0,0:40:40.39,0:40:44.04,Default,,0000,0000,0000,,the bytes that it printed, &c. Dialogue: 0,0:40:44.04,0:40:47.16,Default,,0000,0000,0000,,Similar as with "fd", sometimes\Nit's not as useful Dialogue: 0,0:40:48.40,0:40:50.62,Default,,0000,0000,0000,,using one specific tool or another and Dialogue: 0,0:40:50.62,0:40:55.78,Default,,0000,0000,0000,,in fact, as ripgrep, there are several\Nother tools. Like "ack", Dialogue: 0,0:40:55.78,0:40:57.70,Default,,0000,0000,0000,,is the original grep alternative that was Dialogue: 0,0:40:57.70,0:41:00.67,Default,,0000,0000,0000,,written. Then the silver searcher, Dialogue: 0,0:41:00.67,0:41:04.09,Default,,0000,0000,0000,,"ag", was another one... and they're all Dialogue: 0,0:41:04.09,0:41:05.59,Default,,0000,0000,0000,,pretty much interchangeable so Dialogue: 0,0:41:05.59,0:41:07.63,Default,,0000,0000,0000,,maybe you're at a system that has one and Dialogue: 0,0:41:07.63,0:41:09.67,Default,,0000,0000,0000,,not the other, just knowing that you can Dialogue: 0,0:41:09.67,0:41:12.04,Default,,0000,0000,0000,,use these things with these tools can be Dialogue: 0,0:41:12.04,0:41:15.55,Default,,0000,0000,0000,,fairly useful. Lastly, I want to cover Dialogue: 0,0:41:15.55,0:41:19.78,Default,,0000,0000,0000,,how you go about, not finding files\Nor code, but how you go about Dialogue: 0,0:41:19.78,0:41:22.54,Default,,0000,0000,0000,,finding commands that you already Dialogue: 0,0:41:22.54,0:41:30.16,Default,,0000,0000,0000,,some time figured out. The first, obvious\Nway is just using the up arrow, Dialogue: 0,0:41:30.16,0:41:34.54,Default,,0000,0000,0000,,and slowly going through all your history,\Nlooking for these matches. Dialogue: 0,0:41:34.54,0:41:36.49,Default,,0000,0000,0000,,This is actually not very efficient, as Dialogue: 0,0:41:36.49,0:41:42.58,Default,,0000,0000,0000,,you probably guessed. So the bash\Nhas ways to do this more easily. Dialogue: 0,0:41:42.58,0:41:44.62,Default,,0000,0000,0000,,There is the "history" command, that will Dialogue: 0,0:41:44.62,0:41:49.18,Default,,0000,0000,0000,,print your history. Here I'm in zsh and\Nit only prints some of my history, but Dialogue: 0,0:41:49.18,0:41:54.07,Default,,0000,0000,0000,,if I say, I want you to print everything\Nfrom the beginning of time, it will print Dialogue: 0,0:41:54.07,0:41:58.22,Default,,0000,0000,0000,,everything from the beginning\Nof whatever this history is. Dialogue: 0,0:41:58.22,0:42:00.70,Default,,0000,0000,0000,,And since this is a lot of results, Dialogue: 0,0:42:00.70,0:42:02.59,Default,,0000,0000,0000,,maybe we care about the ones where we Dialogue: 0,0:42:02.59,0:42:08.49,Default,,0000,0000,0000,,use the "convert" command to go from some\Ntype of file to some other type of file. Dialogue: 0,0:42:08.49,0:42:12.94,Default,,0000,0000,0000,,Some image, sorry. Then, we're getting all Dialogue: 0,0:42:12.94,0:42:15.85,Default,,0000,0000,0000,,these results here, about all the ones Dialogue: 0,0:42:15.85,0:42:18.12,Default,,0000,0000,0000,,that match this substring. Dialogue: 0,0:42:21.28,0:42:24.61,Default,,0000,0000,0000,,Even more, pretty much all shells by default will Dialogue: 0,0:42:24.61,0:42:27.13,Default,,0000,0000,0000,,link "Ctrl+R", the keybinding, Dialogue: 0,0:42:27.13,0:42:29.68,Default,,0000,0000,0000,,to do backward search. Here we Dialogue: 0,0:42:29.68,0:42:31.57,Default,,0000,0000,0000,,have backward search, where we can Dialogue: 0,0:42:31.57,0:42:34.75,Default,,0000,0000,0000,,type "convert" and it's finding the Dialogue: 0,0:42:34.75,0:42:36.61,Default,,0000,0000,0000,,command that we just typed. And if we just Dialogue: 0,0:42:36.61,0:42:38.62,Default,,0000,0000,0000,,keep hitting "Ctrl+R", it will Dialogue: 0,0:42:38.62,0:42:41.74,Default,,0000,0000,0000,,kind of go through these matches and Dialogue: 0,0:42:41.74,0:42:44.26,Default,,0000,0000,0000,,it will let re-execute it Dialogue: 0,0:42:44.26,0:42:49.24,Default,,0000,0000,0000,,in place. Another thing that you can do, Dialogue: 0,0:42:49.24,0:42:51.07,Default,,0000,0000,0000,,related to that, is you can use this Dialogue: 0,0:42:51.07,0:42:53.83,Default,,0000,0000,0000,,really nifty tool called "fzf", which is Dialogue: 0,0:42:53.83,0:42:56.28,Default,,0000,0000,0000,,like a fuzzy finder, like it will... Dialogue: 0,0:42:57.10,0:42:58.48,Default,,0000,0000,0000,,It will let you do kind of Dialogue: 0,0:42:58.48,0:43:02.20,Default,,0000,0000,0000,,like an interactive grep. We could do Dialogue: 0,0:43:02.20,0:43:06.37,Default,,0000,0000,0000,,for example this, where we can cat our Dialogue: 0,0:43:06.37,0:43:10.03,Default,,0000,0000,0000,,example.sh command, that will print Dialogue: 0,0:43:10.03,0:43:11.68,Default,,0000,0000,0000,,print to the standard output, and then we Dialogue: 0,0:43:11.68,0:43:14.29,Default,,0000,0000,0000,,can pipe it through fzf. It's just getting Dialogue: 0,0:43:14.29,0:43:18.49,Default,,0000,0000,0000,,all the lines and then we can\Ninteractively look for the Dialogue: 0,0:43:18.49,0:43:21.85,Default,,0000,0000,0000,,string that we care about. And the nice Dialogue: 0,0:43:21.85,0:43:26.35,Default,,0000,0000,0000,,thing about fzf is that, if you enable\Nthe default bindings, it will bind to Dialogue: 0,0:43:26.35,0:43:33.67,Default,,0000,0000,0000,,your "Ctrl+R" shell execution and now Dialogue: 0,0:43:33.67,0:43:36.49,Default,,0000,0000,0000,,you can quickly and dynamically like Dialogue: 0,0:43:36.49,0:43:41.70,Default,,0000,0000,0000,,look for all the times you try to\Nconvert a favicon in your history. Dialogue: 0,0:43:42.02,0:43:46.38,Default,,0000,0000,0000,,And it's also like fuzzy matching,\Nwhereas like by default in grep Dialogue: 0,0:43:46.38,0:43:49.42,Default,,0000,0000,0000,,or these things you have to write a regex or some Dialogue: 0,0:43:49.42,0:43:52.36,Default,,0000,0000,0000,,expression that will match within here. Dialogue: 0,0:43:52.36,0:43:54.61,Default,,0000,0000,0000,,Here I'm just typing "convert" and "favicon" and Dialogue: 0,0:43:54.61,0:43:57.37,Default,,0000,0000,0000,,it's just trying to do the best scan, Dialogue: 0,0:43:57.37,0:44:01.35,Default,,0000,0000,0000,,doing the match in the lines it has. Dialogue: 0,0:44:01.35,0:44:06.19,Default,,0000,0000,0000,,Lastly, a tool that probably you have\Nalready seen, that I've been using Dialogue: 0,0:44:06.19,0:44:08.41,Default,,0000,0000,0000,,for not retyping these extremely long Dialogue: 0,0:44:08.41,0:44:13.08,Default,,0000,0000,0000,,commands is this "history\Nsubstring search", where Dialogue: 0,0:44:13.94,0:44:15.66,Default,,0000,0000,0000,,as I type in my shell, Dialogue: 0,0:44:15.67,0:44:19.63,Default,,0000,0000,0000,,and both F fail to mention but both face Dialogue: 0,0:44:19.63,0:44:22.76,Default,,0000,0000,0000,,which I think was originally introduced,\Nthis concept, and then Dialogue: 0,0:44:22.76,0:44:25.76,Default,,0000,0000,0000,,zsh has a really nice implementation) Dialogue: 0,0:44:25.76,0:44:26.80,Default,,0000,0000,0000,,what it'll let you do is Dialogue: 0,0:44:26.80,0:44:31.30,Default,,0000,0000,0000,,as you type the command, it will\Ndynamically search back in your Dialogue: 0,0:44:31.30,0:44:34.42,Default,,0000,0000,0000,,history to the same command\Nthat has a common prefix, Dialogue: 0,0:44:34.98,0:44:36.90,Default,,0000,0000,0000,,and then, if you... Dialogue: 0,0:44:39.10,0:44:42.10,Default,,0000,0000,0000,,it will change as the match list stops Dialogue: 0,0:44:42.10,0:44:44.11,Default,,0000,0000,0000,,working and then as you do the Dialogue: 0,0:44:44.12,0:44:49.76,Default,,0000,0000,0000,,right arrow you can select that\Ncommand and then re-execute it. Dialogue: 0,0:45:05.80,0:45:09.92,Default,,0000,0000,0000,,We've seen a bunch of stuff... I think I have Dialogue: 0,0:45:09.94,0:45:16.18,Default,,0000,0000,0000,,a few minutes left so I'm going\Nto cover a couple of tools to do Dialogue: 0,0:45:16.18,0:45:20.06,Default,,0000,0000,0000,,really quick directory listing\Nand directory navigation. Dialogue: 0,0:45:20.06,0:45:30.02,Default,,0000,0000,0000,,So you can always use the "-R" to recursively\Nlist some directory structure, Dialogue: 0,0:45:30.02,0:45:35.16,Default,,0000,0000,0000,,but that can be suboptimal, I cannot\Nreally make sense of this easily. Dialogue: 0,0:45:36.34,0:45:44.46,Default,,0000,0000,0000,,There's tool called "tree" that will\Nbe the much more friendly form of Dialogue: 0,0:45:44.46,0:45:47.50,Default,,0000,0000,0000,,printing all the stuff, it will\Nalso color code based on... Dialogue: 0,0:45:47.50,0:45:50.68,Default,,0000,0000,0000,,here for example "foo" is blue\Nbecause it's a directory and Dialogue: 0,0:45:50.68,0:45:55.10,Default,,0000,0000,0000,,this is red because it has execute permissions. Dialogue: 0,0:45:55.10,0:46:00.22,Default,,0000,0000,0000,,But we can go even further than\Nthat. There's really nice tools Dialogue: 0,0:46:00.22,0:46:04.58,Default,,0000,0000,0000,,like a recent one called "broot" that\Nwill do the same thing but here Dialogue: 0,0:46:04.58,0:46:07.30,Default,,0000,0000,0000,,for example instead of doing\Nthis thing of listing Dialogue: 0,0:46:07.30,0:46:09.16,Default,,0000,0000,0000,,every single file, for example in bar Dialogue: 0,0:46:09.16,0:46:11.40,Default,,0000,0000,0000,,we have these "a" through "j" files, Dialogue: 0,0:46:11.40,0:46:14.26,Default,,0000,0000,0000,,it will say "oh there are more, unlisted here". Dialogue: 0,0:46:15.08,0:46:18.20,Default,,0000,0000,0000,,I can actually start typing and it will again Dialogue: 0,0:46:18.20,0:46:21.54,Default,,0000,0000,0000,,again facily match to the files that are there Dialogue: 0,0:46:21.54,0:46:24.80,Default,,0000,0000,0000,,and I can quickly select them\Nand navigate through them. Dialogue: 0,0:46:24.80,0:46:28.38,Default,,0000,0000,0000,,So, again, it's good to know that Dialogue: 0,0:46:28.38,0:46:33.34,Default,,0000,0000,0000,,these things exist so you don't\Nlose a large amount of time Dialogue: 0,0:46:34.24,0:46:36.18,Default,,0000,0000,0000,,going for these files. Dialogue: 0,0:46:37.88,0:46:40.50,Default,,0000,0000,0000,,There are also, I think I have it installed Dialogue: 0,0:46:40.50,0:46:44.83,Default,,0000,0000,0000,,also something more similar to what\Nyou would expect your OS to have, Dialogue: 0,0:46:44.83,0:46:49.96,Default,,0000,0000,0000,,like Nautilus or one of the Mac\Nfinders that have like an Dialogue: 0,0:46:49.96,0:46:59.26,Default,,0000,0000,0000,,interactive input where you can just use your\Nnavigation arrows and quickly explore. Dialogue: 0,0:46:59.26,0:47:03.85,Default,,0000,0000,0000,,It might be overkill but you'll\Nbe surprised how quickly you can Dialogue: 0,0:47:03.85,0:47:07.84,Default,,0000,0000,0000,,make sense of some directory structure\Nby just navigating through it. Dialogue: 0,0:47:07.84,0:47:12.78,Default,,0000,0000,0000,,And pretty much all of these tools\Nwill let you edit, copy files... Dialogue: 0,0:47:12.78,0:47:16.88,Default,,0000,0000,0000,,if you just look for the options for them. Dialogue: 0,0:47:17.60,0:47:20.10,Default,,0000,0000,0000,,The last addendum is kind of going places. Dialogue: 0,0:47:20.10,0:47:24.48,Default,,0000,0000,0000,,We have "cd", and "cd" is nice, it will get you Dialogue: 0,0:47:26.12,0:47:30.06,Default,,0000,0000,0000,,to a lot of places. But it's pretty handy if Dialogue: 0,0:47:30.07,0:47:33.19,Default,,0000,0000,0000,,you can like quickly go places, Dialogue: 0,0:47:33.19,0:47:36.73,Default,,0000,0000,0000,,either you have been to recently or that Dialogue: 0,0:47:36.73,0:47:40.60,Default,,0000,0000,0000,,you go frequently. And you can do this in Dialogue: 0,0:47:40.60,0:47:42.52,Default,,0000,0000,0000,,many ways there's probably... you can start Dialogue: 0,0:47:42.52,0:47:44.32,Default,,0000,0000,0000,,thinking, oh I can make bookmarks, I can Dialogue: 0,0:47:44.32,0:47:46.66,Default,,0000,0000,0000,,make... I can make aliases in the shell, Dialogue: 0,0:47:46.66,0:47:49.02,Default,,0000,0000,0000,,that we will cover at some point, Dialogue: 0,0:47:49.02,0:47:53.02,Default,,0000,0000,0000,,symlinks... But at this point, Dialogue: 0,0:47:53.02,0:47:54.91,Default,,0000,0000,0000,,programmers have like built all these Dialogue: 0,0:47:54.91,0:47:56.80,Default,,0000,0000,0000,,tools, so programmers have already figured Dialogue: 0,0:47:56.80,0:47:59.52,Default,,0000,0000,0000,,out a really nice way of doing this. Dialogue: 0,0:47:59.52,0:48:01.93,Default,,0000,0000,0000,,One way of doing this is using what is Dialogue: 0,0:48:01.93,0:48:05.76,Default,,0000,0000,0000,,called "auto jump", which I\Nthink is not loaded here... Dialogue: 0,0:48:14.14,0:48:20.10,Default,,0000,0000,0000,,Okay, don't worry. I will cover it\Nin the command line environment. Dialogue: 0,0:48:21.96,0:48:25.58,Default,,0000,0000,0000,,I think it's because I disabled\Nthe "Ctrl+R" and that also Dialogue: 0,0:48:25.58,0:48:31.31,Default,,0000,0000,0000,,affected other parts of the script.\NI think at this point if anyone has Dialogue: 0,0:48:31.31,0:48:35.48,Default,,0000,0000,0000,,any questions that are related to this,\NI'll be more than happy to answer Dialogue: 0,0:48:35.48,0:48:37.51,Default,,0000,0000,0000,,them, if anything was left unclear. Dialogue: 0,0:48:37.51,0:48:42.86,Default,,0000,0000,0000,,Otherwise, a there's a bunch of\Nexercises that we wrote, kind of Dialogue: 0,0:48:42.86,0:48:46.55,Default,,0000,0000,0000,,touching on these topics and we\Nencourage you to try them and Dialogue: 0,0:48:46.55,0:48:48.56,Default,,0000,0000,0000,,come to office hours, where we can help Dialogue: 0,0:48:48.56,0:48:54.57,Default,,0000,0000,0000,,you figure out how to do them, or some\Nbash quirks that are not clear.