Shell Scripting Lesson 1
Hey guys, this is Matt. Kids on one and today is going to be, um, shell scripting lesson one.
The deal with this is that there's a programming language basically built into terminal that you probably don't know about. It's not really considerably a programming language, but it's pretty powerful, and there are a bunch of scripts on your computer that use it that you probably don't know about.
So let me just, um, explain this to you. When you open up terminal or iTerm or something like that, you'll notice that, um, basically this command line will come up, and it lets you type commands. But, say you use something like iTerm instead of terminal; yeah, it's exactly the same, except for maybe the GUI of the application, but the text is all the same.
Let me explain to you why, because this is actually a terminal application running in terminal. Um, so terminal is just one big terminal application running in terminal called bash or sh or a sh or whatever these are called. Shells, and the shell is basically something that handles the login, handles commands, handles, you know, prompts, and handles closing programs and running new programs and stuff like that.
So shell, this might, my shell is processing this. If I hit like a sh, it's not installed, but zsh I think I might have; you can see it's a different prompt here. The shell is a little bit different. If I type csh, it might be in here. Then this is, um, shell scripting or more like c. But I'm basically, let me just explain to you what your default shell is. It's bash, be a sh.
Um, and this is basically a shell that processes commands. You might have noticed that the command line, if you type while true to enter, it'll ask you to type another one. You can type echo, you know, hi, and then you can type done, and then it'll keep on printing out hi, something like that. Well, that was just a shell script that we wrote there because the point is that this shell is like a programming language, and you can program it at the command line.
Normally, typically, you can only program one line programs. So if you type ls, that's a one line program. The only command in that whole program is ls. Or, if you want to type multiple commands, it can be ls semicolon space ls dash out our /. Then first, I'll type ls then gl a special r /. Instantly, but, um, maybe you don't enjoy that so much and you want to do something else.
So maybe you want to write a shell script. If you do want to learn some shell scripting, feel free to watch our shell scripting to video, and it will show you how to write a program effectively and easily using bash and terminal. It's pretty powerful; it allows you to, um, do if statements, check if files exist, have command line parameters.
Info 101 was written mostly with, um, Perl, but there was a lot of shell scripting involved in it. I'll just show you real quick, um, what info 101 really looks like. If you take a look at the source code of it, because it's actually open source, just if you open it with Mac VI, em. So I'll just open it with Mac VI m, and right here you can see, um, it's all shell scripting. This is really simple shell.
So info 101 was written mostly in shell scripting. That is why you should learn shell scripting; it's just pretty powerful. So thanks for watching. Makinson on, check out RM's shell scripting to video right now because it'll have all the information you need on how to shell script. So, I thanks for watching him b...