Difference between revisions of "Intro to Bash Scripting"
m |
|||
Line 24: | Line 24: | ||
== Class Outline == | == Class Outline == | ||
− | Day One: What is a "variable". We work on the idea of a variable, using shell expansion to assign to variables, expanding variables in text, system variables, and exporting environment variables. | + | Day One: What is a "script" and what is a "variable". We will write a simple script in nano, with comments, a "shebang" line, appropriate permissions, and simple output. We work on the idea of a variable, using shell expansion to assign to variables, expanding variables in text, system variables, and exporting environment variables. |
Day Two: "For loops". We will explore the for loop in all its glory, going over lists stored in variables and lines of input from a file. | Day Two: "For loops". We will explore the for loop in all its glory, going over lists stored in variables and lines of input from a file. |
Revision as of 07:51, 15 October 2008
Class Description
The class: a four week course on Tues evenings covering basic and intermediate scripting in the bash shell. We will examine about a file with about 15 lines of code together each night, modify the code, run it, and come up with our own scripts. We will also get to know the "Advanced Bash Scripting Guide" [1] and the Gnu "Bash Reference Manual" [2] in some depth and learn to research and solve our own programming problems. User projects are encouraged -- bring your problems and we will solve them together!
I am a fifth year Ph D student from Berkeley in Demography, writing an anthropology of a small lumber town in Oregon. I have worked as a programmer in Linux for almost 10 years, and I am currently employed part time as a software project manager at Portland State.
The first class target: Oct 28, 5:00 to 6:30, 2008. I will probably have to take off a week and delay a class in the middle of the sequence.
http://www.gnu.org/software/bash/manual/bashref.html
Class Outline
Day One: What is a "script" and what is a "variable". We will write a simple script in nano, with comments, a "shebang" line, appropriate permissions, and simple output. We work on the idea of a variable, using shell expansion to assign to variables, expanding variables in text, system variables, and exporting environment variables.
Day Two: "For loops". We will explore the for loop in all its glory, going over lists stored in variables and lines of input from a file.
Day Three: Conditionals ("if then" statements). We will show how to write "if" and "case" statements, and then work on "file tests".
Day Four: Scripts, functions, command line parameters. We will show how to write a script file, get input at the command line, and look at how to write functions.
Class approach
Each class period I will have a file of code that is on the wiki. We will go over it together, showing you how to look up questions using online documentation. You will type examples from this file with modifications to make your own scripts, run them from the command line, and fix bugs.