Unleashing the Shell Hands-On UNIX System Administration DeCal Week 6 28 February 2011

Similar documents
CS 301. Lecture 05 Applications of Regular Languages. Stephen Checkoway. January 31, 2018

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

More Scripting and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

5/20/2007. Touring Essential Programs

Shells & Shell Programming (Part B)

Essentials for Scientific Computing: Stream editing with sed and awk

Part III. Shell Config. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26,

BNF, EBNF Regular Expressions. Programming Languages,

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

Useful Unix Commands Cheat Sheet

DAVE LIDDAMENT INTRODUCTION TO BASH

Lecture 18 Regular Expressions

CSE 374 Programming Concepts & Tools. Brandon Myers Winter 2015 Lecture 4 Shell Variables, More Shell Scripts (Thanks to Hal Perkins)

9.2 Linux Essentials Exam Objectives

Lecture 5. Essential skills for bioinformatics: Unix/Linux

Answers to AWK problems. Shell-Programming. Future: Using loops to automate tasks. Download and Install: Python (Windows only.) R

Lecture 3 Tonight we dine in shell. Hands-On Unix System Administration DeCal

Basic Linux (Bash) Commands

COMP2100/2500 Lecture 17: Shell Programming II

5/8/2012. Exploring Utilities Chapter 5

CS Unix Tools & Scripting Lecture 7 Working with Stream

CSE 401/M501 18au Midterm Exam 11/2/18. Name ID #

Chapter 4. Unix Tutorial. Unix Shell

STATS Data Analysis using Python. Lecture 15: Advanced Command Line

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

CSCI 2132 Software Development. Lecture 7: Wildcards and Regular Expressions

Shell Programming Systems Skills in C and Unix

While Statement Examples. While Statement (35.15) Until Statement (35.15) Until Statement Example

Introduction Variables Helper commands Control Flow Constructs Basic Plumbing. Bash Scripting. Alessandro Barenghi

Practical 02. Bash & shell scripting

CSE 374: Programming Concepts and Tools. Eric Mullen Spring 2017 Lecture 4: More Shell Scripts

Essentials for Scientific Computing: Bash Shell Scripting Day 3

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

Basic Shell Scripting Practice. HPC User Services LSU HPC & LON March 2018

Wildcards and Regular Expressions

Command Interpreters. command-line (e.g. Unix shell) On Unix/Linux, bash has become defacto standard shell.


Subcontractors. bc math help for the shell. interactive or programatic can accept its commands from stdin can accept an entire bc program s worth

Chapter-3. Introduction to Unix: Fundamental Commands

Module 8 Pipes, Redirection and REGEX

Scripting Languages Course 1. Diana Trandabăț

Open up a terminal, make sure you are in your home directory, and run the command.

Cisco IOS Shell. Finding Feature Information. Prerequisites for Cisco IOS.sh. Last Updated: December 14, 2012

Output with printf Input. from a file from a command arguments from the command read

ECS 120 Lesson 7 Regular Expressions, Pt. 1

Essential Linux Shell Commands

LING 408/508: Computational Techniques for Linguists. Lecture 5

Shells and Shell Programming

COMP 4/6262: Programming UNIX

CS 124/LINGUIST 180 From Languages to Information. Unix for Poets Dan Jurafsky

Perl and R Scripting for Biologists

B a s h s c r i p t i n g

CSE 374 Programming Concepts & Tools. Laura Campbell (thanks to Hal Perkins) Winter 2014 Lecture 6 sed, command-line tools wrapup

Lecture 01: welcome and intro what LSD and Unix have in common

Shell Programming Overview

CS246 Spring14 Programming Paradigm Notes on Linux

Assignment 3, Due October 4

Linux Text Utilities 101 for S/390 Wizards SHARE Session 9220/5522

CS160A EXERCISES-FILTERS2 Boyd

Regex, Sed, Awk. Arindam Fadikar. December 12, 2017

Getting to grips with Unix and the Linux family

Lecture 4. Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions?

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

Introduction: What is Unix?

Lab #2 Physics 91SI Spring 2013

Mastering Modern Linux by Paul S. Wang Appendix: Pattern Processing with awk

Vi & Shell Scripting

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

CSE374 Winter 2016, Midterm Examination February 8, 2016 Please do not turn the page until the bell rings.

sottotitolo A.A. 2016/17 Federico Reghenzani, Alessandro Barenghi

Lab 4: Shell Scripting

Today. Review. Unix as an OS case study Intro to Shell Scripting. What is an Operating System? What are its goals? How do we evaluate it?

CSCI 2132: Software Development. Norbert Zeh. Faculty of Computer Science Dalhousie University. Shell Scripting. Winter 2019

Understanding bash. Prof. Chris GauthierDickey COMP 2400, Fall 2008

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

Basic Survival UNIX.

A Brief Introduction to the Linux Shell for Data Science

CS434 Compiler Construction. Lecture 3 Spring 2005 Department of Computer Science University of Alabama Joel Jones

Consider the following program.

CSC209. Software Tools and Systems Programming.

Shells and Shell Programming

Today s Lecture. The Unix Shell. Unix Architecture (simplified) Lecture 3: Unix Shell, Pattern Matching, Regular Expressions

bash Scripting Introduction COMP2101 Winter 2019

Lecture 8: Structs & File I/O

unix intro Documentation

CS Advanced Unix Tools & Scripting

A shell can be used in one of two ways:

Unix Shell scripting. Dr Alun Moon 7th October Introduction. Notation. Spaces

Shell Programming (bash)

Basic Shell Scripting

Computer Systems and Architecture

UNIX II:grep, awk, sed. October 30, 2017

Introduction To Linux. Rob Thomas - ACRC

CSE 390a Lecture 7. Regular expressions, egrep, and sed

Linux Command Line Interface. December 27, 2017

bash Tests and Looping Administrative Shell Scripting COMP2101 Fall 2017

CSE 303 Lecture 7. Regular expressions, egrep, and sed. read Linux Pocket Guide pp , 73-74, 81

Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

UNIX System Programming Lecture 3: BASH Programming

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands

Transcription:

Unleashing the Shell Hands-On UNIX System Administration DeCal Week 6 28 February 2011

Last time Compiling software and the three-step procedure (./configure && make && make install). Dependency hell and package managers. Lab assignment: compiling nethack. (If you re not yet in a final project group, ask around some groups are a few short.)

source: http://ars.userfriendly.org/cartoons/?id=19990815

Grok awk? grep: match input based on a pattern (or regular expression more on that later). You ve already used it, but today s lecture will let you unlock its full potential. awk and sed: powerful programming languages designed for text processing. We ll be using awk for field extraction and sed for regex find-and-replace searches.

source: http://xkcd.com/208/

Classical Regular Expressions Regular expressions denote formal languages, which are setsofstrings (of symbols from some alphabet). Appropriate since internal structure not all that complex yet. Expression R denotes language L(R): L(ɛ) =L("") ={""}. If c is a character, L(c) ={"c"}. If R 1, R 2 are r.e.s, L(R 1 R 2 )={x 1 x 2 x 1 L(R 1 ),x 2 L(R 2 )}. L(R 1 R 2 )=L(R 1 ) L(R 2 ). L(R ) =L(ɛ) L(R) L(R R). L((R)) = L(R). Precedence is * (highest), concatenation, union (lowest). Parentheses also provide grouping. Last modified: Fri Jan 21 00:27:29 2011 CS164: Lecture #2 4 source: http://www-inst.eecs.berkeley.edu/~cs164/sp11/lectures/lecture2.pdf

Regular expressions don t worry, you don t need to understand set theory to use regexes! Syntax and features vary from program to program (consult documentation to see what exactly you can do), but these basics are universal.

Regular expressions Most characters match themselves ( cat matches cat, bobcats, catastrophe ). [a-z] is a character class that matches one character from the specified set. [^a-z] matches one character not in the set.. (dot) matches any character. ^ and $ match start and end of line.

Regular expressions * matches the preceding symbol any number of times, + at least one time, and? at most one time. () (parentheses) group symbols and (pipe) separates alternatives ( hat cat ). \1, \2, \3 refer to the nth grouped subexpression. (cat)\1 matches catcat.

Examples Experiment! Any good editor will have regular expression support (or use grep). ^$ matches an empty line. Hint: grep -v. #.*$ matches everything from a hash mark to end-of-line (config file comment). [a-z]+@[a-z]+\.(org net com) naively matches email addresses. To do it right

(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^\"\r\\] \\. (?:(?:\r\n)? [ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\ [\]])) "(?:[^\"\r\\] \\. (?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)? [ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?: (?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*))* (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r \n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^\"\r\\] \\. (?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\ \".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?: [^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r \n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*) (?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r \n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^\"\r\\] \ \. (?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["() <>@,;:\\".\[\]])) "(?:[^\"\r\\] \\. (?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?: \r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000- \031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*) (?:[^()<>@,;:\ \".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^\"\r\\] \\. (?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*:(?:(?:\r \n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^\"\r\\] \\. (?:(?:\r\n)?[ \t])) *"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^ \"\r\\] \\. (?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\ ["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)? [ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*))* (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^\"\r\\] \\. (?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^() <>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)? [ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*)(?:\. (?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)? [ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^\"\r\\] \\. (?: (?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\ [\]])) "(?:[^\"\r\\] \\. (?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)? [ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?: (?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)(?:,\s*(?:(?:[^()<>@,;:\ \".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^\"\r\\] \\. (?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?: (?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^\"\r\\] \\. (?:(?:\r\n)?[ \t])) *"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r \\] \\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*))* (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^\"\r \\] \\. (?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\ ["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)? [ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+ (?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^() <>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^\"\r\\] \\. (?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?: \.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) "(?:[^\"\r\\] \\. (?:(?:\r\n)? [ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\\".\[\]])) \ [([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ \Z (?=[\["()<>@,;:\ \".\[\]])) \[([^\[\]\r\\] \\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*))*)?;\s*) source: http://www.ex-parrot.com/pdw/mail-rfc822-address.html

Examples Backreferences (\1, \2, \3 ) are most useful when doing regex replacements. Garcia, Dan Harvey, Brian Hilfinger, Paul Sinclair, Alistair Shewchuk, Jonathan What does sed -E -e s/([a-za-z]+), ([A-Za-z]+)/\2 \1/g do to this file?

sed sed -e s/old/new/g replaces old with new globally. Add the -E flag for extended (modern) regular expressions. sed -e s/old/new/g file > file will clobber your file, not update it be careful! To edit in-place, use -i. And there s more! RTFM for details.

awk awk {print $1} prints its input s first field. By default, fields are delimited by any number of spaces (change the field separator with the -F option). ls -l /etc awk {print $NF is owned by $3} extracts the filename and owner fields.

Miscellany cut extracts sections of its input you can select arbitrary bytes, characters, or fields (with whatever delimiter you like). e.g., getent passwd cut -f1,5 -d: tr deletes or replaces (translates) characters. Only uses stdin (not UUOC!). e.g., cat /etc/group tr -d '\n' e.g., echo go bears tr a e

Anatomy of a script A shell script is, at its simplest, a plain text file containing a list of commands. Scripts usually have shebang lines (e.g., #!/bin/sh) indicating what program to process them with, so they can be run as ordinary programs. Shell scripts can have variables, functions, control flow

Variables Assignment: VARNAME=value. Variables can be lowercase, but are usually uppercase. Can also use substitution, as in EDITOR=`whereis vim`. Reference: echo $VARNAME. Note that echo $VARNAME doesn t evaluate the variable.

Variables bash provides some variables to aid in shell scripting. Here are a few: $# number of arguments passed to your script. (./script foo bar baz => 3.) $0, $1, $2 arguments ($0 is your script, like argv[0] in C s main() function). $@ all arguments in one variable.

Functions Function declarations, by example: defenestrate() { } echo Throwing $@ out the window. defenestrate your homework Note that arguments are handled with special variables, not declared as in C.

Control flow For loops iterate over everything in a list. If you need to work with numbers, use {0..100} or `seq 0 100`. Example: for DOCTOR in {hartnell,troughton,pertwee,baker, davison,colin,mccoy,mcgann,eccleston,tennant}; do mkdir -p /mnt/$doctor mount -o loop /xen/domains/$doctor/disk.img /mnt/ $DOCTOR done

Control flow bash also supports while loops. E.g.: while true; do sleep 100 uptime # includes load info done (If you actually want to do something like this, try the watch command.)

Control flow If expressions rely on a command called test, which is often abbreviated to [. There are lots of tests available test(1) is well worth a read. Here s an example: if [ $# -eq 0 ]; then echo Usage: $0 [args] exit 1 fi

and more! Instead of deluging you with the details, I ve just given you a high-level overview of shell shenanigans. If there s something specific you d like to know how to do, please ask!