Difference between revisions of "Intro to Bash Scripting"

From FreekiWiki
Jump to navigation Jump to search
m
 
(165 intermediate revisions by 6 users not shown)
Line 1: Line 1:
== Class Description ==
+
[[Intro to bash scripting old|old content]] has moved here.
  
The class: a four week course on Tues evenings covering basic and
+
= Class Description =
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
+
A six-week course on Saturdays covering basic and intermediate scripting in Bash! This course will teach you all you need to know to begin writing your own scripts. You can use these to automate system administration tasks and write your own custom commands. Scripting will give you use of the full power and flexibility of Bash. The course aims to teach a strong grasp of the basic concepts through practical examples. We will teach these one at a time, with back up exercises and notes for use outside the classroom.  
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
+
Dates and Time: Saturdays, 1:00 - 3:00pm
take off a week and delay a class in the middle of the sequence.
 
  
http://tldp.org/LDP/abs/html/
+
May 15, 22, (no class Memorial Day weekend, May 29)
 +
June 5, 12, 19, 26
  
http://www.gnu.org/software/bash/manual/bashref.html
+
Location: Free Geek Classroom
  
== Class Outline ==
+
Cost: $60 for entire series; $30 for Free Geek volunteers!
  
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.
+
To register:
 +
Send an e-mail to: Laurel (laurel@freegeek.org) and to instructor Paul Munday (paul.munday@gmail.com)
  
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.
+
In your email, please include the following:
 +
* Why you want to take the class
 +
* Other classes you have taken at Free Geek
 +
* Your computer experience
  
Day Three: Conditionals ("if then" statements). We will show how to write "if" and "case" statements, and then work on "file tests".
+
'''Please note: The class is a sequence. Please don't register if you don't think you can attend all 6 classes. There will be more chances to learn Bash at Free Geek -- promise!'''
  
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 Tutor ==
  
== Class approach ==
+
Paul Munday. I've worked as a Linux sysadmin for 12 years as well as an IT trainer focusing on FLOSS.
  
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 documentationYou will type examples from this file with modifications to make your own scripts, run them from the command line, and fix bugs.
+
== Class Requirements ==
 +
 
 +
No previous programming experience is necessary but you will need to be familiar with use of the command line/terminal (bash shell). If you have taken the basic command line for builders class this should be sufficient. 
 +
 
 +
= Class Outline =
 +
 
 +
* '''Lesson 1: First Steps & Variables'''. The first lesson covers a basic introduction to scripting: what it is, and how to write one; good scripting style and how to comment your scripts; data & strings; variables --- a first building block for scripts [http://www.gatheringstorms.org/wiki/doku.php?id=bash_course:lesson_1  Class Notes]
 +
* '''Lesson 2: Math with Bash & Tests.''' The second lesson covers doing basic math with bash and introduces control structures, specifically tests (a.k.a conditionals). [http://www.gatheringstorms.org/wiki/doku.php?id=bash_course:lesson_2  Class Notes]
 +
*  '''Lesson 3 : Loops.''' More on control structures, specifically loops and how to build basic menus. [http://www.gatheringstorms.org/wiki/doku.php?id=bash_course:lesson_3  Class Notes] [http://www.gatheringstorms.org/wiki/doku.php?id=bash_course:lesson_3_exercises Sample Exercises] [http://www.gatheringstorms.org/wiki/doku.php?id=bash_course:lesson_3_answers Answers]
 +
* ''Lesson 4 : Arrays and Functions'' Lesson four covers arrays, a data structure with multiple elements and functions --- a useful way to reuse code and keep it organized. [http://www.gatheringstorms.org/wiki/doku.php?id=bash_course:lesson_4  Class Notes] [http://www.gatheringstorms.org/wiki/doku.php?id=bash_course:lesson_4_exercises Sample Exercises]
 +
*  '''Lesson 5: Regular Expressions, Sed and Awk.''' Regular expressions are a handy way to match text strings, combined with sed and awk they provide a powerful way to search and edit large amounts of data. [http://www.gatheringstorms.org/wiki/doku.php?id=bash_course:lesson_5  Class Notes]
 +
* '''Lesson 6: Putting it all together.''' Lesson 6 will walk through the construction of a functional and useful script, step by step, so you can learn how to put them together and how you can use them for systems administration.
  
 
[[Category: Classes]]
 
[[Category: Classes]]

Latest revision as of 14:42, 6 July 2010

old content has moved here.

Class Description

A six-week course on Saturdays covering basic and intermediate scripting in Bash! This course will teach you all you need to know to begin writing your own scripts. You can use these to automate system administration tasks and write your own custom commands. Scripting will give you use of the full power and flexibility of Bash. The course aims to teach a strong grasp of the basic concepts through practical examples. We will teach these one at a time, with back up exercises and notes for use outside the classroom.

Dates and Time: Saturdays, 1:00 - 3:00pm

May 15, 22, (no class Memorial Day weekend, May 29) June 5, 12, 19, 26

Location: Free Geek Classroom

Cost: $60 for entire series; $30 for Free Geek volunteers!

To register: Send an e-mail to: Laurel (laurel@freegeek.org) and to instructor Paul Munday (paul.munday@gmail.com)

In your email, please include the following:

  • Why you want to take the class
  • Other classes you have taken at Free Geek
  • Your computer experience

Please note: The class is a sequence. Please don't register if you don't think you can attend all 6 classes. There will be more chances to learn Bash at Free Geek -- promise!

Class Tutor

Paul Munday. I've worked as a Linux sysadmin for 12 years as well as an IT trainer focusing on FLOSS.

Class Requirements

No previous programming experience is necessary but you will need to be familiar with use of the command line/terminal (bash shell). If you have taken the basic command line for builders class this should be sufficient.

Class Outline

  • Lesson 1: First Steps & Variables. The first lesson covers a basic introduction to scripting: what it is, and how to write one; good scripting style and how to comment your scripts; data & strings; variables --- a first building block for scripts Class Notes
  • Lesson 2: Math with Bash & Tests. The second lesson covers doing basic math with bash and introduces control structures, specifically tests (a.k.a conditionals). Class Notes
  • Lesson 3 : Loops. More on control structures, specifically loops and how to build basic menus. Class Notes Sample Exercises Answers
  • Lesson 4 : Arrays and Functions Lesson four covers arrays, a data structure with multiple elements and functions --- a useful way to reuse code and keep it organized. Class Notes Sample Exercises
  • Lesson 5: Regular Expressions, Sed and Awk. Regular expressions are a handy way to match text strings, combined with sed and awk they provide a powerful way to search and edit large amounts of data. Class Notes
  • Lesson 6: Putting it all together. Lesson 6 will walk through the construction of a functional and useful script, step by step, so you can learn how to put them together and how you can use them for systems administration.