Introduction to Shell Scripting
Prof. Brian D. Davison
Computer Science & Engineering, Lehigh University
Announcements
- Project #4 (debugging) online, due Thursday
- Friday's quiz is on the shell scripting from today, as well as anything from previous classes
- I will link to bash tutorials, references after class
- Today's schedule
- Return short quiz #5 -- scores ranged from 2 to 10, mean 6.5
- Course Feedback
- Introduction to Shell Scripting
- See UNIX Shells by Example, Ch 1&2, focus on bash
Course Feedback
- Course is essentially half over -- I will be filing mid-term grades
soon (tomorrow)
- We have covered
- Using UNIX
- Programming with C
- We still have to cover
- UNIX Shell programming
- UNIX Systems Programming
- This is your chance to have an impact on how the rest of the course will be structured
- We will still have a second exam, and a final
- We will stlll have some labs and lectures
- What should be different about the rest of the class? What should stay the same? What will help you learn the best?
Automating UNIX Operations
- You know many UNIX commands
- You know how to program in C and other languages
- You have also seen how to connect UNIX commands with pipes
- UNIX commands can also be placed into shell scripts
- What is a shell?
- What is a script?
- Try writing one
What does the shell do?
- After you type a command, the shell
- Performs history substitution (if necessary)
- Breaks up the command line into tokens
- Updates the shell history
- Processes quotes
- Performs alias substitution
- Sets up redirection, background processing, and pipes
- Performs variable substitution (e.g., $user)
- Performs command substitution (ls `cat filelist.txt`)
- Performs filename substitution (handling wildcards, etc.)
- Executes the program