Join Scott Simpson for an in-depth discussion in this video What you need to know before continuing, part of Up and Running with Bash Scripting.
If you're a system administrator, or you want to become one, this is a good place to start. I'm going to assume that you have some familiarity with working at an OS-10 or a Linux Command Line. This course doesn't cover individual commands and syntax, that are used at the command line itself, in depth. If that's what you're looking for, a better place to start would be the first eight chapters of Kevin Skoglund's UNIX for Mac OS X Users, here on lynda.com. If you're a Linux user, don't be scared off by the Mac OS X in the name of the course. It's a great guide to the born-again shell. If you're already familiar with a command line, you're in the right place.
You'll be extending that knowledge into creating multi-line scripts. If you're already familiar with programming, you should have a pretty easy time of following along. If not don't worry. If you get stuck with any of the general programming concepts that I'll be talking about pause this course and jump over to Simon Allerdice's Foundations of Programming: Fundamentals course here on lynda.com. Though he uses java script to show basic programming concepts, most of the concepts will apply here with bash, even if it looks a little different. And remember, if you're unclear on what a particular command is, you've already got a reference right at your finger tips with the man command.
Just type MAN followed by the command you want more information about and you'll dive right into the system's reference manual. You can even use MAN BASH to read about Bash itself. I'll be using a terminal session connected to Ubuntu 12.04 Server running on a DigitalOcean Droplet. I recommend DigitalOcean if you want to get up and running with a Linux instance easily and don't want to deal with setting up a virtual machine of your own. And I'll be using the nano text editor. Nano does some handy syntax highlighting, it's light weight and it's pretty easy to use. Feel free to use your favorite plain text editor, like vim, or emacs if you like.
Or a program like SublimeText, TextWrangler, TextMate, or gEdit if you want a graphical user interface. Your platform might be a Linux virtual machine, a Linux host you have access through, or the terminal in Mac OS X. If you're using the Mac, note that Nano on OS X doesn't do the syntax highlighting you'll see in Linux version by default. At the time of recording, the current version of Mac OS X, which is 10.9, still only has bash version 3.2.51, that's pretty old, and bash has moved on since then. When I talk about something that won't work with older version of bash, I'll be sure to mention it.
Because of this, I recommend you use an up to date version of Linux to follow along with this course. Various web hosts may also have an older version of bash installed, so it's a good idea before going any further to check what version your environment has. At the command line, you can type echo $BASH_VERSION. Of course, you can install updated versions of Bash on all these platforms, but doing so is beyond the scope of this course. I recommend you search on the internet for how to do this for your particular platform. Now, Bash doesn't come with Windows. So if you have Windows, I strongly recommend setting up a Linux virtual machine, or connecting to a Linux machine with a program like PuTTY.
There are a number of ways you can run Bash directly on a Windows machine, including Siguin and MenGW, but installing those is up to you and is beyond the scope of this course. And on top of that, the version often lags behind. Bash lives in the world of Mac OS10 and Linux, and if you're looking to make scripts to run on Windows, you'll probably want to look into batch scripts instead.
- What is Bash?
- Managing output with grep, awk, and cut
- Understanding Bash script syntax
- Creating a basic Bash script
- Displaying text with "echo"
- Working with numbers, strings, and arrays
- Reading and writing text files
- Working with loops
- Using functions
- Getting user input during execution
- Ensuring a response