Homework / Exams HW7 due today Exam #3 next class

Slides:



Advertisements
Similar presentations
CST8177 awk. The awk program is not named after the sea-bird (that's auk), nor is it a cry from a parrot (awwwk!). It's the initials of the authors, Aho,
Advertisements

Shell Scripting Printing; Loops and Logic printf: formatted print printf is a more standardized method to print text to the screen. It can be used instead.
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
Linux Shell Script. Shell script The first line is used to specify shell program #!/bin/sh Variables variable=“text” variable=0 variable=`program arguments`
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
23-Jun-15Advanced Programming Spring 2002 bash Henning Schulzrinne Department of Computer Science Columbia University.
Scripting Languages and C-Shell. What is a scripting language ? Script is a sequence of commands written as plain text and run by an interpreter (shell).
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Shell Scripts 4 A shell usually interprets a single line of input, but we can also create a file containing a number of lines of commands to be interpreted.
Unix Shell Scripts. What are scripts ? Text files in certain format that are run by another program Examples: –Perl –Javascript –Shell scripts (we learn.
CSCI 330 T HE UNIX S YSTEM C Shell Programming. S TEPS TO C REATE S HELL P ROGRAMS Specify shell to execute program Script must begin with #! (pronounced.
Using Unix Shell Scripts to Manage Large Data
Shell Programming. Shell Scripts (1) u Basically, a shell script is a text file with Unix commands in it. u Shell scripts usually begin with a #! and.
Shell Control Structures CSE 2031 Fall August 2015.
Shell Scripting Awk (part1) Awk Programming Language standard unix language that is geared for text processing and creating formatted reports but it.
Sydney Opera House. Week Three Agenda Administrative Issues Link of the week Review week two lab assignment This week’s expected outcomes Next lab assignment.
Chapter 5 Bourne Shells Scripts By C. Shing ITEC Dept Radford University.
LIN 6932 Unix Lecture 6 Hana Filip. LIN 6932 HW6 - Part II solutions posted on my website see syllabus.
Chapter 6: Shell Programming
An Introduction to Unix Shell Scripting
Writing C-shell scripts #!/bin/csh # Author: Ken Berman # Date: # Purpose: display command and parameters echo $0 echo $argv[*]
July 17, 2003Serguei A. Mokhov, 1 Shells and Shell Scripts COMP 444/5201 Revision 1.3 January 25, 2005.
1 Shell Scripting (C shell) SungHo Maeung 10/27/2000 Tutorial section Computer Science Lab.
Lecture 4  C Shell Scripts(Chapter 10). Shell script/program  Shell script: a series of shell commands placed in an ASCII text file  Commands include.
LINUX System : Lecture 6 Shell Programming
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 11: Shell.
Shell Scripting AFNOG IX Rabat, Morocco May 2008.
Shell Programming. 222 Lecture Overview  Shell variables  Shell scripts  Control flow and Boolean operators  Shell programming tips  Shell programming.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
Sed, awk, & perl CS 2204 Class meeting 13 *Notes by Mir Farooq Ali and other members of the CS faculty at Virginia Tech. Copyright 2003.
Lecture 24CS311 – Operating Systems 1 1 CS311 – Lecture 24 Outline Final Exam Study Guide Note: These lecture notes are not intended replace your notes.
Introduction to Perl “Practical Extraction and Report Language” “Pathologically Eclectic Rubbish Lister”
LIN Unix Lecture 7 Hana Filip. LIN Text Processing Command Line Utility Programs (cont.) sed LAST WEEK wc sort tr uniq awk TODAY join paste.
LIN Unix Lecture 5 Unix Shell Scripts. LIN Command Coordination ; && || command1 ; command2 Interpretation: Do command 1. Then do command.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Chapter Twelve sed, awk & perl1 System Programming sed, awk & perl.
CSCI 330 UNIX and Network Programming Unit IX: Shell Scripts.
16-Dec-15Advanced Programming Spring 2002 sed and awk Henning Schulzrinne Dept. of Computer Science Columbia University.
1 Unix/Linux commands and shell programming-Part 2 (Dr. Mohamed El Bachir Menai)
Perl Lab #11 Intro to Perl Debbie Bartlett. Perl Lab #1 2 Perl Practical Extraction and Report Language –or- Pathologically Eclectic Rubbish Lister Created.
Sed. Class Issues vSphere Issues – root only until lab 3.
1 Lecture 10 Introduction to AWK COP 3344 Introduction to UNIX.
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 Writing Shell Scripts Professor Ching-Chi Hsu 1998 年 4 月.
Sed and awk CS 2204 Class meeting 13. © Mir Farooq Ali, sed Stream editor Originally derived from ed line editor Used primarily for non interactive.
PZ02CX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ02CX - Perl Programming Language Design and Implementation.
1 © 2012 John Urrutia. All rights reserved. Chapter 09 The TC Shell.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Shell Control Structures CSE 2031 Fall June 2016.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/9/2006 Lecture 6 – String Processing.
Organization of Programming Languages Meeting 37 April 18, 2016.
CS 350 Lecture 3 UNIX/Linux Shells by İlker Korkmaz and Kaya Oğuz.
Shell Control Structures
Using Unix Shell Scripts to Manage Large Data
CSC 352– Unix Programming, Fall 2012
Perl Programming Language Design and Implementation (4th Edition)
Sydney Opera House.
LINUX System : Lecture 5 (English-Only Lecture)
Shell Script Assignment 1.
UNIX Reference Sheets CSE 2031 Fall 2010.
Shell Programming.
Shell Control Structures
CSC 352– Unix Programming, Fall, 2011
Shell Control Structures
Chapter 5 Bourne Shells Scripts
Introduction to Perl Learning Objectives:
Introduction to Bash Programming, part 3
Review.
The Linux Command Line Chapter 24
Presentation transcript:

Homework / Exams HW7 due today Exam #3 next class Covers Chapter 5 through end of Chapter 7 and Appendix B Standard Library Plus UNIX Shells / Processes / Shell Scripts Homework #8 due class 28 Review for Exam#3

Shell Scripts Yet another programming language!  Save a sequence of UNIX commands in a file Three different script languages with their own syntax – one for each type of UNIX shell!  C shell script file names have suffix .csh File permission for execute must be set chmod u+x filename.csh Then, type the filename at the UNIX prompt: % filename.csh

C Shell Script Language Builds on existing shell commands Adds Expressions and Assignments Adds comments, labels, and goto Adds C-like Control Statements foreach … end if … then … else … endif switch … case … endsw

C Shell Script Language Assignment of expression value to variable set a = 3 set b = 5 @ a = $a + $b echo a = $a Arithmetic only for integer variables

C Shell Script Language Comment Syntax # is start of a comment to end of line # must be first character in file (for C shell script) #!/bin/tcsh  Shebang gives path name to shell Label Syntax name: # Usually on a line by itself goto Syntax goto name

C Shell Script Language Syntax for: foreach … end foreach name (wordList) … # use $name as loop variable end

C Shell Script Language Syntax for: if … then … else … endif if (expr1) then list 1 # shell commands else if (expr2) then list 2 # shell commands else list 3 # shell commands endif

C Shell Script Language Syntax for: switch … case … endsw switch (expr) case pattern1: list # shell commands breaksw # break out of this case case pattern2: … # same as above default: endsw

C Shell Script Example blade64(26)% pwd /home/bobw/cs240 blade64(27)% cat showhw.csh # showhw.csh  AT LEAST 1 COMMENT LINE! foreach subdir (hw1 hw2 hw3 hw4 hw5 hw6 hw7 hw8) cd $subdir ls cd .. end

C Shell Script Example blade64(28)% showhw.csh soln reverse.in soln trim.in vt.in bits.c bits.h buggy.c showbits.c soln makefile soln explore.c soln alloc.c alloc.h alloctest.c makefile soln test.in makefile mapss.c mapss.h soln testmapss.c differ.in1 differ.in2 soln

C Shell Script Example blade64(94)% cat foo.csh # set a = 3 set b = 5 @ a = $a + $b if ($a > $b) then echo $a is greater than $b else echo $a is not greater than $b endif blade64(95)% foo.csh 8 is greater than 5 blade64(96)%

AWK Programs Yet another programming language!  Authors: Aho, Weinberger, and Kernighan Invoke the awk utility with a program on a file awk program defines operations to do on each line blade64(43)% cat awk1 BEGIN { print "start of file: ", FILENAME} { print NF, $1} END {print "end of file"}

AWK Programs blade64(44)% cat foo.txt Now is the time for all good men to come to the aid blade64(45)% awk -f awk1 foo.txt start of file: foo.txt 4 Now 4 for 5 to end of file

Perl Scripts Yet another programming language!  Practical Extraction and Reporting Language aka Pathologically Eclectic Rubbish Lister Falls between a Shell script and a C program Often used instead of shell scripts, awk, sed There are a2p and s2p translators available You can actually write O-O perl scripts!

Perl Scripts blade64(46)% cat test.pl print "What is your name? "; chomp($name = <STDIN>); $length = length $name; ($length == 3)? print "$name has $length characters.\n": die; blade64(47)% perl test.pl What is your name? Bob Bob has 3 characters. blade64(48)% perl test.pl What is your name? Robert Died at test.pl line 4, <STDIN> line 1.

Review for Exam #3 The floor is now open for questions