CHAPTER 8 (skip , ) CHAPTER 10

Slides:



Advertisements
Similar presentations
Bash startup files Linux/Unix files stty 1.  midterms  bash startup files  stty 2.
Advertisements

Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
More about Shells1-1 More about Shell  Shells (sh, csh, ksh) are m Command interpreters Process the commands you enter m High-level programming languages.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Linux+ Guide to Linux Certification, Second Edition
Information Networking Security and Assurance Lab National Chung Cheng University 1 if condition Condition is defined as: "Condition is nothing but comparison.
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Chapter 8 The Bourne Again Shell Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, Original Notes.
CTEC 1863 – Operating Systems Shell Scripting. CTEC F2 Overview How shell works Command line parameters –Shift command Variables –Including.
Shell Programming, or Scripting Shirley Moore CPS 5401 Fall August 29,
Chapter 15 Introductory Bash Programming
Agenda Control Flow Statements Purpose test statement if / elif / else Statements for loops while vs. until statements case statement break vs. continue.
Introduction to Shell Script Programming
1 Operating Systems Lecture 3 Shell Scripts. 2 Shell Programming 1.Shell scripts must be marked as executable: chmod a+x myScript 2. Use # to start a.
1 Operating Systems Lecture 3 Shell Scripts. 2 Brief review of unix1.txt n Glob Construct (metacharacters) and other special characters F ?, *, [] F Ex.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
An Introduction to Unix Shell Scripting
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
Workbook 6 – Part 2 The Bash Shell
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to UNIX / Linux - 10 Dr. Jerry Shiao, Silicon Valley University.
CSC 352– Unix Programming, Spring 2015 March 2015 Shell Programming (Highlights only)
A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 5: Scripting in Linux Chapter 27: Programming the Bourne Again Shell By Fred R. McClurg Linux.
1 © 2001 John Urrutia. All rights reserved. Chapter 10 using the Bourne Again Shell.
1. 2 What is a Shell Script? A Text File With Instructions Executable  Why shell script? Simply and quickly initiate a complex series of tasks or a.
Chapter 10: BASH Shell Scripting Fun with fi. In this chapter … Control structures File descriptors Variables.
Customizing Linux Environment Tutorial 4 ENGR 3950U / CSCI 3020U Operating Systems Instructor: Dr. Kamran Sartipi.
Writing Scripts Hadi Otrok COEN 346.
UNIX shell environments CS 2204 Class meeting 6 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
1 © 2000 John Urrutia. All rights reserved. Session 5 The Bourne Shell.
CSCI 330 UNIX and Network Programming Unit IX: Shell Scripts.
Shell Programming Features “Full” programming language “Full” programming language Conditional statements Conditional statements Arithmetic, String, File,
Chapter 8: The Bourne Again Shell It’s a command interpreter, it’s a programming language, and it makes a mean martini.
Jozef Goetz, expanded by Jozef Goetz, 2006 Credits: Parts of the slides are based on slides created by textbook authors, Syed M. Sarwar, Robert.
Linux+ Guide to Linux Certification, Second Edition
Introduction to Bash Shell. What is Shell? The shell is a command interpreter. It is the layer between the operating system kernel and the user.
1 © 2012 John Urrutia. All rights reserved. Chapter 09 The TC Shell.
1 UNIX Operating Systems II Part 2: Shell Scripting Instructor: Stan Isaacs.
Linux Administration Working with the BASH Shell.
Agenda Customizing a Unix/Linux account Environment Introduction to Start-up Files (.bash_profile,.bashrc,.profile,.kshrc) Safe Methods for Changing Start-up.
Introduction to the bash Shell (Bourne-Again SHell)
ULI101 Week 10. Lesson Overview ● Shell Start-up and Configuration Files ● Shell History ● Alias Statement ● Shell Variables ● Introduction to Shell Scripting.
COMP075 OS2 Bash Scripting. Scripting? BASH provides access to OS functions, like any OS shell Also like any OS shell, BASH includes the ability to write.
CS 350 Lecture 3 UNIX/Linux Shells by İlker Korkmaz and Kaya Oğuz.
Department of Computer Engineering
Introduction to Shells
Shell Features CSCI N321 – System and Network Administration
CSC 352– Unix Programming, Spring 2016, Final Exam Guide
CSC 352– Unix Programming, Fall 2012
Shell Scripting March 1st, 2004 Class Meeting 7.
CIRC Summer School 2017 Baowei Liu
Shell Programming (ch 10)
CSE 303 Concepts and Tools for Software Development
Agenda Control Flow Statements Purpose test statement
What is Bash Shell Scripting?
Pepper (Help from Dr. Robert Siegfried)
LING 408/508: Computational Techniques for Linguists
John Carelli, Instructor Kutztown University
CSE 303 Concepts and Tools for Software Development
Linux Shell Script Programming
Chapter 8 The Bourne Again Shell
Unix Shell Environments
Chapter 5 The Bourne Shell
CSC 352– Unix Programming, Fall, 2011
Introduction to Bash Programming, part 3
Bash Scripting CS 580U - Fall 2018.
Basic shell scripting CS 2204 Class meeting 7
Presentation transcript:

CHAPTER 8 (skip 299-310, 333-354) CHAPTER 10 John Carelli, Instructor Kutztown University carelli@kutztown.edu

Interactive login shell First shell to provide a prompt upon login Executes the following in order /etc/profile .bash_profile .bash_login .profile Interactive nonlogin shell When a new terminal is opened only executes .bashrc source filename execute commands in named file OR execute it as a shell script (next)

Shell Scripts (again) Shell Script: an executable (text) file that contains shell commands. When the shell script is run, the commands in it get executed bash script #!/bin/bash Must be executable # comments execution in current shell with . (dot) changes to variables persist in current shell ex: testvar

Variable name Assignment Display Array variables Declare statement  $ Array variables  ${name[*]} … or ${name[@]}  ${#name[*]} … or ${#name[@]}  ex: arrayvars Declare statement declare varname declare –r varname # readonly – like const unset

Single quote ' Double quote “ Backslash \ metacharacter “escape” Back quote ` command substitution ex: quotescript

alias unalias Quotes in aliases only matters if alias contains a command substitution single: substitution occurs when executed double: substitution occurs when created ex: aliases

Arithmetic Expressions Double parenthesis evaluate an arithmetic expression syntax: (( arithmetic expression )) (( z = x + y )) Can drop $ in variable names ex: arith

Operators if – then - fi if-else elif ex: operators Test and [] Arithmetic Relational String comparison -n -z File testing if – then - fi if-else elif ex: operators

Control Statements while for until break continue ex: looping case select ex: menu (see also: getopt) 8

Command-line arguments shift ex: shifting $# Number of positional parameters $$ PID $? Exit status of most recently executed command $0 Program name $1 - $n Positional parameters $* All positional parameters $@

Definition Arguments return export there is no scoping – variables are global except for cmd line args (can’t change those) ex: functest

type read exec trap