Chapter 6 Dealing with quotes. Dealing with Quotes and slashes grep Susan phonebook grep Susan Goldberg phonebook  results in an error  grep ‘Susan.

Slides:



Advertisements
Similar presentations
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
Advertisements

CIS 118 – Intro to UNIX Shells 1. 2 What is a shell? Bourne shell – Developed by Steve Bourne at AT&T Korn shell – Developed by David Korn at AT&T C-shell.
Perl Process Management Software Tools. Slide 2 system Perl programs can execute shell commands (Bourne shell) using the system function. system("date");
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.
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
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.
QUOTATION This chapter teaches you about a unique feature of the shell programming language: the way it interprets quote characters. Basically, the shell.
Unix Filters Text processing utilities. Filters Filter commands – Unix commands that serve dual purposes: –standalone –used with other commands and pipes.
Shell Script Examples.
Shell Control Structures CSE 2031 Fall August 2015.
CTEC 1863 – Operating Systems Shell Scripting. CTEC F2 Overview How shell works Command line parameters –Shift command Variables –Including.
Chapter 15 Introductory Bash 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.
An Introduction to Unix Shell Scripting
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.
The if construct The general format of the if command is: Every command has exit status If the exit status is zero, then the commands that follow between.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.
Introduction to Linux OS (IV) AUBG ICoSCIS Team Prof. Volin Karagiozov March, 09 – 10, 2013 SWU, Blagoevgrad.
1 Shell Scripting (C shell) SungHo Maeung 10/27/2000 Tutorial section Computer Science Lab.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
CS465 - UNIX The Bourne Shell.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
Workbook 6 – Part 2 The Bash Shell
Beyond sh Not everyone is as fond of UNIX as most other people. The tutorial talks about the dark side of UNIX.
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
Shell Advanced Features. Module 8 Shell Advanced Features ♦ Introduction In Linux systems, the shells are often referred to as command line interfaces.
Chapter Four I/O Redirection1 System Programming Shell Operators.
Introduction to Unix (CA263) Passing Arguments By Tariq Ibn Aziz Dammam Community College.
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.
CIT 140: Introduction to ITSlide #1 CIT 140: Introduction to IT Shell Programming.
1 © 2000 John Urrutia. All rights reserved. Session 5 The Bourne Shell.
Shell Programming Features “Full” programming language “Full” programming language Conditional statements Conditional statements Arithmetic, String, File,
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Introduction to Unix (CA263) Quotes By Tariq Ibn Aziz.
CSCI 330 UNIX and Network Programming Unit IV Shell, Part 2.
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.
Agenda The Bourne Shell – Part II Special Characters Ambiguous File Reference Variable Names and Values User Created Variables Read-only Variables (Positional.
Introduction to Unix (CA263) Command File By Tariq Ibn Aziz.
Compunet Corporation Introduction to Unix (CA263) Round and Round By Tariq Ibn Aziz Dammam Community College.
© Prepared By: Razif Razali 1 TMK 265: UNIX SYSTEM CHAPTER FOUR – QUOTING IN DETAIL.
Lesson 6-Using Utilities to Accomplish Complex Tasks.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
Various 2. readonly readonly x=4 x=44 #this will give an error (like what in java?)
Chapter 16 Advanced Bourne Shell Programming. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Objectives To discuss numeric data processing.
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.
Shell Control Structures CSE 2031 Fall June 2016.
Shell Control Structures
Bash Introduction (adapted from chapters 1 and 2 of bash Cookbook by Albing, Vossing, & Newham) CPTE 440 John Beckett.
The UNIX Shell Learning Objectives:
UNIX System Overview.
Unix Scripting Session 4 March 27, 2008.
Intro to PHP & Variables
The Linux Command Line Chapter 7
CSCI The UNIX System Shell Substitution and Sequences
UNIX Reference Sheets CSE 2031 Fall 2010.
Linux Shell Script Programming
Lab 5: Complex Inputs.
Shell Control Structures
Shell Control Structures
Chapter 3 The UNIX Shells
CSC 4630 Meeting 4 January 29, 2007.
Introduction to Bash Programming, part 3
Introduction to Unix (CA263) Passing Arguments
Presentation transcript:

Chapter 6 Dealing with quotes

Dealing with Quotes and slashes grep Susan phonebook grep Susan Goldberg phonebook  results in an error  grep ‘Susan Goldberg’ phonebook allows the shell to ignore spaces the single quote ignores the $ sign and * symbol

Double quotes Some things in double quotes are NOT ignored – in other words the shell WILL interpret  $ signs  back quotes (on the tilde key)  backslashes  other double quotes  newlines

Examples $x=* $echo $x addresses intro lotaspaces nu names $echo ‘$x’ $x $echo “$x” *

Hiding quotes with quotes double quotes hide single quotes and single quotes hide double quotes $x=“’Good day, ‘ she said” $echo $x ‘Good day, ‘ she said $y=‘ “Good quotes are hard to find” ‘ $echo $y “Good quotes are hard to find”

The Backslash the backslash serves as a way of putting quotes around the next character $echo \\ \ $echo ‘\’ \

The Backslash (cont’d) The backslash goes as far as causing the shell to ignore a hard return this is useful for typing in long commands $lines=command1\ >command2 $echo $lines command1command2

The Back Quote this is used to tell the shell to execute the following command $echo The date and time is `date` The date and time is Wed Jan 24 14:20:34 PST 2007 be aware that this typically is no longer the preferred method, but you may run across it

The $(…) or command substitution Construct $echo “The date and time is: $(date)” The date and time is Wed Jan 24 14:20:34 PST 2007 keep in mind that within single quotes the command substitution construct does not work, but in double quotes it does

Examples echo There are $(who | wc – l) users logged in with single quotes  echo ‘$(who | wc –l) tells how many users are logged in’ with double quotes  echo “You have $(ls | wc – l) files in your directory

more $(…) stuff to preserve newlines / hard returns use double quotes $filelist=$(ls) $echo $filelist – yields everything on one line $echo “$filelist” – yields the files on separate lines

Nifty stuff to put the contents of a file into a variable use the cat command $namelist=$(cat names1) $echo “$namelist” - will list all the names with newlines mail $(cat unames) < memo – will the memo to all users listed in unames who are on your system

Nested commands $filename=/usrs/steve/memos $firstchar=$(echo $filename | cut –c1) $filename=$(echo $filename | tr “$firstchar” “^”) $echo $filename ^usrs^steve^memos can also be written as

Nested commands (cont’d) $filename=/usrs/steve/memos $filename=$(echo $filename | tr “$(echo $filename | cut –c1)” “^”) $echo $filename

The expr operator used by older systems – only does integer arithmetic $expr $ some quirks  expr 17 * 6 - yields an error  expr “17 * 6” - yields 17 * 6  expr 17 \* 6 – yields 102