RaspberryPi shell programming - getting to know Busybox and its Shell
Duration: 3 Days
The goals of this course are to get build on your basic Linux skills and to introduce you to the world of Shell programming ( or shell scripting as it is often referred to). The course will make use of not only Linux running on the Raspberry Pi, but, also regular Linux running either standalone or on VMWare or VirtualBoxrunning on a Window platform. As well as covering the simpler (Ash - A Shell) that is part of Busybox we will also cover the basics of Bash shell programming (Bash being the most common shell found on larger Linux installations). Here, again, we are conforming to our policy of getting more people confident in using Linux. We feel that this is especially important for those in the teaching profession as Linux is, sadly, very under-represented in most schools. There will also be time on the course to ask questions that might have arisen from materials presented in the introductory course.
Linux in particular, and Unix in general has very much of a "Lego" philosophy behind it. The idea is to provide a lot of well designed small tools and components that do one particular job and do it well, and then to provide a mechanism for combining these components to achieve more complex goals. It is the purpose of the shell programming language to provide the means for combining these components together. Think of a shell program as a kind of glue language. When developing shell scripts use will be made of various Linux command line tools and utilities (and there will be a chance to refresh your understanding of these commands and utilities).
Each attendee will be given a RaspberryPi to take with them after the course, and, much more importantly the knowledge and confidence to apply their new found shell programming skills not only to Linux running on a PC or a RasbperryPi, but to other Linux devices also.
Probably the next daunting task after installing Linux, finding your way around it, and getting to know how to use some of the command and utilities is to learn how to read and write shell scripts.
You'll learn how to write shell scripts to create and process batches of files. You'll also learn something of rapid prototyping - because this is an area that shell programming is good for. You'll gain insights into the Unix philosophy of automating work wherever possible e.g. automating uploading of content to a web server, automating the configuration and installation of applications.
You will also be introduced to the philosophy of mini-langages as exemplified e.g. by sed and awk. Amongst other skills you will learn some quite powerful and useful sed and awk one liners. We will also tell you about Cygwin, which will enable to apply some of your knowledge of Linux command line tools and utilities and shell programming to the Windows environment.
Course Prerequisites and Target Audience
- Overview of command line tools and utilities
- Introduction to Cygwin - bringing Linux tools and utilities to Microsoft Windows
- Accessing and using manual pages
- Basic utilities
- Simple filters: cat, wc, head, tail, tr, uniq...
- Sorting and searching tools: find, sort, grep, wildcards
- System reporting tools: ls, du, df, ps, netstat, uname, date ...
- Stream editing with sed
- Building solutions by combining tools
- Searching and matching text with regular expressions
- Regular Expression syntax
- Examples using grep
- Other contexts for using regular expressions
- Substitutions using tagged regular expressions in sed and vi
- Creating Shell Scripts
- Passing arguments to a script
- Built-in variables and environment variables
- I/O with echo and read
- Redirecting input and output
- Arithmetic and string operations
- Flow control in the shell
- Conditional execution with if ... else
- Testing exit status of a command
- Testing file properties
- Looping with for, while and until
- Multiway branching using case
- Busybox Ash and Bash compared
- Advanced shell features
- Defining functions and aliases
- Command substitution
- Structuring data with arrays
- Command sequencing and grouping
- Using sed to process documents
- How a stream editor works
- sed as an example mini-language
- Using sed scripts to modify documents - word substitution, rearrangment of text
- Using sed to modify tags in HTML documents or XML documents
- Using awk to process structured input
- How awk processes lines and fields
- Patterns and actions
- Variables, operators and functions
- Formatted output
- Looping and branching in awk
- Putting it all together
- Using pipes and command substitution
- Choosing the right tool for the job
- Incremental development of solutions
- Some common idioms