CSCI 330 UNIX and Network Programming Unit IV Shell, Part 2.

Slides:



Advertisements
Similar presentations
An Introduction to Sed & Awk Presented Tues, Jan 14 th, 2003 Send any suggestions to Siobhan Quinn
Advertisements

CIS 240 Introduction to UNIX Instructor: Sue Sampson.
CSCI 330 T HE UNIX S YSTEM Regular Expressions. R EGULAR E XPRESSION A pattern of special characters used to match strings in a search Typically made.
7 Searching and Regular Expressions (Regex) Mauro Jaskelioff.
CS 497C – Introduction to UNIX Lecture 22: - The Shell Chin-Chih Chang
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Shell Programming Software Tools. Slide 2 Shells l A shell can be used in one of two ways: n A command interpreter, used interactively n A programming.
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
CS 497C – Introduction to UNIX Lecture 20: - The Shell Chin-Chih Chang
Regular Expressions. u A regular expression is a pattern which matches some regular (predictable) text. u Regular expressions are used in many Unix utilities.
The UNIX Shells 1. What is a Unix shell? 2. A few common shells in the Unix & Linux. A. Bourne shell B. Korn shell C. C shell D. Bash-the default shell.
Shell Programming Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn the.
Shell Script Examples.
Chapter 4: UNIX File Processing Input and Output.
Regular Expressions A regular expression defines a pattern of characters to be found in a string Regular expressions are made up of – Literal characters.
Last Updated March 2006 Slide 1 Regular Expressions.
Overview of the grep Command Alex Dukhovny CS 265 Spring 2011.
System Programming Regular Expressions Regular Expressions
Writing Shell Scripts ─ part 1 CSE 2031 Fall September 2015.
1 Operating Systems Lecture 3 Shell Scripts. 2 Brief review of unix1.txt n Glob Construct (metacharacters) and other special characters F ?, *, [] F Ex.
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 8 Shell.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
REGULAR EXPRESSIONS. Lexical Analysis Lexical analysers can be constructed by programs such as LEX These programs employ as input a description of the.
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
Introduction to Linux OS (IV) AUBG ICoSCIS Team Prof. Volin Karagiozov March, 09 – 10, 2013 SWU, Blagoevgrad.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
Writing Shell Scripts ─ part 3 CSE 2031 Fall October 2015.
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
CS465 - UNIX The Bourne Shell.
Workbook 6 – Part 2 The Bash Shell
Introduction to Unix – CS 21 Lecture 6. Lecture Overview Homework questions More on wildcards Regular expressions Using grep Quiz #1.
Chapter 2: Java Fundamentals
CSC 352– Unix Programming, Spring 2015 April 28 A few final commands.
Lesson 2 1.Commands 2.Filename Substitution 3.I/O Redirection 4.Command Grouping 5.Shell Responisibilites Review of the Basics.
I/O Redirection and Regular Expressions February 9 th, 2004 Class Meeting 4.
Regular Expressions Todd Kelley CST8207 – Todd Kelley1.
Shell Advanced Features. Module 8 Shell Advanced Features ♦ Introduction In Linux systems, the shells are often referred to as command line interfaces.
I/O Redirection & Regular Expressions CS 2204 Class meeting 4 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
CSCI 330 T HE UNIX S YSTEM Bash shell. B ASH S HELL S PECIFICS Shell login and logout files Shell variables Prompt History IO redirection 2 CSCI 330 -
Shell Programming Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn the.
Regular Expressions CS 2204 Class meeting 6 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
1 Lecture 9 Shell Programming – Command substitution Regular expressions and grep Use of exit, for loop and expr commands COP 3353 Introduction to UNIX.
CSCI 330 UNIX and Network Programming Unit IX: Shell Scripts.
CSCI The UNIX System Shell Data Handling: Redirection and Piping
Introduction to Unix (CA263) Quotes By Tariq Ibn Aziz.
CSCI 330 UNIX and Network Programming Unit IV Shell, Part 2.
Agenda Positional Parameters / Continued... Command Substitution Bourne Shell / Bash Shell / Korn Shell Mathematical Expressions Bourne Shell / Bash Shell.
Ajmer Singh PGT(IP) Programming Fundamentals. Ajmer Singh PGT(IP) Java Character Set Character set is a set of valid characters that a language can recognize.
Agenda The Bourne Shell – Part II Special Characters Ambiguous File Reference Variable Names and Values User Created Variables Read-only Variables (Positional.
-Joseph Beberman *Some slides are inspired by a PowerPoint presentation used by professor Seikyung Jung, which was derived from Charlie Wiseman.
Various 2. readonly readonly x=4 x=44 #this will give an error (like what in java?)
Shell scripts – part 1 Cs 302. Shell scripts  What is Shell Script? “Shell Script is series of command written in plain text file. “  Why to Write Shell.
Lesson 4 String Manipulation. Lesson 4 In many applications you will need to do some kind of manipulation or parsing of strings, whether you are Attempting.
Shell Features CSCI N321 – System and Network Administration
Prepared by: Eng. Maryam Adel Abdel-Hady
Looking for Patterns - Finding them with Regular Expressions
The UNIX Shell Learning Objectives:
Lecture 9 Shell Programming – Command substitution
Writing Shell Scripts ─ part 3
Using Linux Commands Lab 3.
Folks Carelli, Instructor Kutztown University
CSC 140: Introduction to IT
The Linux Command Line Chapter 7
UNIX Reference Sheets CSE 2031 Fall 2010.
Lab 5: Complex Inputs.
CSCI The UNIX System Regular Expressions
UNIX and Shell Programming (06CS36)
CSC 4630 Meeting 4 January 29, 2007.
LPI Linux Certification
Presentation transcript:

CSCI 330 UNIX and Network Programming Unit IV Shell, Part 2

more bash shell basics Wildcards Regular expressions Quoting & escaping 2CSCI UNIX and Network Programming

Command Line Behavior Special characters have special meaning: $ variable reference = assignment ! event number ; command sequence ` command substitution > < | i/o redirect & background * ? [ ] { } wildcards regular expressions ‘ “ \ quoting & escaping 3CSCI UNIX and Network Programming

Wildcards: * ? [ ] { } A pattern of special characters used to match file names on the command line * zero or more characters Ex: % rm * % ls *.txt % wc -l assign1.* % cp a*.txt docs ? exactly one character % ls assign?.cc % wc assign?.?? % rm junk.??? 4CSCI UNIX and Network Programming

Wildcards: [ ] { } [...] matches any of the enclosed characters [a-z] matches any character in the range a to z if the first character after the [ is a ! or ^ then any character that is not enclosed is matched within [], [:class:] matches any character from a specific class: alnum, alpha, blank, digit, lower, upper, punct { word1,word2,word3,...} matches any entire word 5CSCI UNIX and Network Programming

Wildcards: [ ] { } examples % wc –l assign[123].cc % ls csci[2-6]30 % cp [A-Z]* dir2 % rm *[!cehg] % echo [[:upper:]]* % cp {*.doc,*.pdf} ~ 6CSCI UNIX and Network Programming

short-hand classes [:alpha:] letters of the alphabet [:alnum:] letters and digits [:upper:] [:lower:] upper/lower case letters [:digit:] digits [:space:] white space [:punct:] punctuation marks 7CSCI UNIX and Network Programming

Quoting & Escaping allows to distinguish between the literal value of a symbol and the symbols used as meta-characters done via the following symbols: Backslash (\) Single quote (‘) Double quote (“) 8CSCI UNIX and Network Programming

Backslash (\) also called the escape character preserve the character immediately following it For example: to create a file named “tools>”, enter: % touch tools\> 9CSCI UNIX and Network Programming

Single Quote (') protects the literal meaning of meta-characters protects all characters within the single quotes exception: it cannot protect itself Examples: % echo 'Joe said "Have fun Joe said "Have fun % echo 'Joe said 'Have fun'' Joe said Have fun 10CSCI UNIX and Network Programming

Double Quote (") protects all symbols and characters within the double quotes, expect for: $ (dollar sign) ! (event number) ` (back quote) \ (backslash) Examples: % echo "I've gone fishing" I've gone fishing % echo "your home directory is $HOME" your home directory is /home/student 11CSCI UNIX and Network Programming

Quoting Examples: % echo "Hello Ray []^?+*{}<>" Hello Ray []^?+*{}<> % echo "Hello $USER" Hello student % echo "It is now `date`" It is now Mon Feb 25 10:24:08 CST 2012 % echo "you owe me \$500" you owe me $500 12CSCI UNIX and Network Programming