© Prepared By: Razif Razali 1 TMK 265: UNIX SYSTEM CHAPTER FOUR – QUOTING IN DETAIL.

Slides:



Advertisements
Similar presentations
Linux Shell Script. Shell script The first line is used to specify shell program #!/bin/sh Variables variable=“text” variable=0 variable=`program arguments`
Advertisements

UNIX Chapter 12 Redirection and Piping Mr. Mohammad Smirat.
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.
EMT 2390L Lecture 4 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
Using Linux Commands Lab 4 1. Create empty files To create an empty file $ touch apple banana grape grapefruit watermelon $ ls -l Using file-matching.
CS 497C – Introduction to UNIX Lecture 22: - The Shell Chin-Chih Chang
Linux+ Guide to Linux Certification, Second Edition
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.
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.
Guide To UNIX Using Linux Third Edition
1 Character Strings and Variables Character Strings Variables, Initialization, and Assignment Reading for this class: L&L,
QUOTATION This chapter teaches you about a unique feature of the shell programming language: the way it interprets quote characters. Basically, the shell.
Introduction to Unix – CS 21 Lecture 5. Lecture Overview Lab Review Useful commands that will illustrate today’s lecture Streams of input and output File.
Using Linux Commands Lab 4. Using the Shell in Linux Commands Syntax  Options: could be added to the commands to change their behavior (-a, -la, --help)
Shell Script Examples.
2 $ command Command Line Options ls –a –l hello hi Command Arguments.
Working with Files Chapter 5. Display a Calendar Display a calendar for a specific month – cal Display a calendar for a specific year – cal 2000.
Chapter Nine Advanced Shell Scripting1 System Programming Advanced Shell Scripting.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Some simple examples First, second, third(with errors) third2.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Shell The Shell The agency that.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Agenda Basic Shell Operations Standard Input / Output / Error Redirection of Standard Input / Output / Error ( >, >>,
Guide To UNIX Using Linux Fourth Edition
Advanced UNIX Shell Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Unix Shells Based on Glass & Abels’ Book CS240 Computer Science II.
An Introduction to Unix Shell Scripting
Title Slide CSS 404/504 The UNIX Operating System (2) By Ralph B. Bisland, Jr.
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 Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
Linux+ Guide to Linux Certification, Third Edition
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Shell Programming Any command or a sequence of UNIX commands stored in a text file is called a shell program. It is common to call this file a command.
LINUX programming 1. INDEX UNIT-III PPT SLIDES Srl. No. Module as per Session planner Lecture No. PPT Slide No. 1.Problem solving approaches in Unix,Using.
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Chapter Four I/O Redirection1 System Programming Shell Operators.
LIN Unix Lecture 5 Unix Shell Scripts. LIN Command Coordination ; && || command1 ; command2 Interpretation: Do command 1. Then do command.
Artificial Intelligence Lecture No. 26 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Shell Scripting – Putting it All Together. Agenda Escaping Characters Wildcards Redirecting Output Chaining and Conditional Chaining Unnamed and Named.
CSCI 330 UNIX and Network Programming Unit IX: Shell Scripts.
Week 9 - Nov 7, Week 9 Agenda I/O redirection I/O redirection pipe pipe tee tee.
CSCI The UNIX System Shell Data Handling: Redirection and Piping
Using Linux Commands Lab 4. Using the Shell in Linux Commands Syntax  Options: could be added to the commands to change their behavior (-a, -la, --help)
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.
Agenda Positional Parameters / Continued... Command Substitution Bourne Shell / Bash Shell / Korn Shell Mathematical Expressions Bourne Shell / Bash Shell.
Chapter 5: The Shell The Man in the Middle. In this chapter … The command line Input, output, and redirection Process management Wildcards and expansion.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
Agenda The Bourne Shell – Part II Special Characters Ambiguous File Reference Variable Names and Values User Created Variables Read-only Variables (Positional.
Command Prompt Chapter 9 Pipes, Filters, and Redirection ©Richard Goldman 11/30/2000 Revised 10/16/2001.
Linux+ Guide to Linux Certification, Second Edition
Lesson 6-Using Utilities to Accomplish Complex Tasks.
Various 2. readonly readonly x=4 x=44 #this will give an error (like what in java?)
Introduction to UNIX (part 2) CSE 2031 Fall March 2016.
© Prepared By: Razif Razali 1 TMK 265: UNIX SYSTEM CHAPTER 8: USER INPUT.
Chapter 15 Introductory Bourne Shell Programming.
Chapter 16 Advanced Bourne Shell Programming. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Objectives To discuss numeric data processing.
Linux Administration Working with the BASH Shell.
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.
CSE 303 Concepts and Tools for Software Development
Using Linux Commands Lab 3.
The Linux Command Line Chapter 7
Chapter 3 The UNIX Shells
CSC 4630 Meeting 4 January 29, 2007.
Presentation transcript:

© Prepared By: Razif Razali 1 TMK 265: UNIX SYSTEM CHAPTER FOUR – QUOTING IN DETAIL

© Prepared By: Razif Razali 2 OVERVIEW –Grouping / gathering Unix command –First program – “Piping” and “redirection”

GROUPING UNIX COMMANDS Normally you type one command at a time, following each command by an ENTER.Normally you type one command at a time, following each command by an ENTER. However, it is possible to put multiple commands on the same line.However, it is possible to put multiple commands on the same line. Example:Example: –$ who; ls; cal –$ (cal 2006; cal 2007; cal 2008) > summer In this case, calendar for 2006, 2007 and 2008 will be redirected into the summer file. © Prepared By: Razif Razali 3

PIPES ( | ) A pipe is a way to connect the output of one program to the input of another program without any temporary file.A pipe is a way to connect the output of one program to the input of another program without any temporary file. A pipe is nothing but a temporary storage place where the output of one command is stored and then passed as the input for second commandA pipe is nothing but a temporary storage place where the output of one command is stored and then passed as the input for second command © Prepared By: Razif Razali 4 Output of 1 st command Take input from 1 st command for this command |

PIPES Suppose you want to display the calendar for the 2006, 2007 and 2008, one right after the other.Suppose you want to display the calendar for the 2006, 2007 and 2008, one right after the other. $ (cal 2006; cal 2007; cal 2008) But when we see the output, you could only see the 2008 calendar.But when we see the output, you could only see the 2008 calendar. Solution – Using pipe in UNIX.Solution – Using pipe in UNIX. Example:Example: –$ (cal 2006; cal 2007; cal 2008) | more Or –$ (cal 2006; cal 2007; cal 2008) | pg © Prepared By: Razif Razali 5

REDIRECTION The shell allow the user to redirect the standard output so that the output goes into an ordinary file instead.The shell allow the user to redirect the standard output so that the output goes into an ordinary file instead. Example:Example: –$ cal 2007 > Calendar.file > is a redirection operator. –$ cal 2008 >> Calendar.file Add output to a file using append operator (>>) –$ mail jones < my.message Send the contents of the file my.message to the user jones. –$ wc output Invokes the wc utility to count the lines, words, and characters in the file input, the redirect the result into the file output. © Prepared By: Razif Razali 6

Example of Redirection © Prepared By: Razif Razali 7 $ cat File1 This is File1 $ cat File2 This is File2 $ cat File1 >> File2 $ cat File2 This is File2 This is File1 $ cat File1 File2 > File3 $ cat File3 This is File2 This is File1 $

Creating a file by direction User also can create a new file by using the redirectionUser also can create a new file by using the redirection Example:Example: © Prepared By: Razif Razali 8 $ ls File1File2 $ ls > File3 $ls File1File2File3

WRITING A FIRST SCRIPT SCRIPT To successfully write a shell script, you have to do three things:To successfully write a shell script, you have to do three things: –Write a script –Give the shell permission to execute it –Put it somewhere the shell can find it © Prepared By: Razif Razali 9

echo Command Use echo command to display text or value of variable.Use echo command to display text or value of variable. echo [options] [string, variables...] Displays text or variables value on screen. Options -n Do not output the trailing new line. -e Enable interpretation of the following backslash escaped characters in the strings: \a alert (bell) \b backspace \c suppress trailing new line \n new line \r carriage return \t horizontal tab \\ backslashecho [options] [string, variables...] Displays text or variables value on screen. Options -n Do not output the trailing new line. -e Enable interpretation of the following backslash escaped characters in the strings: \a alert (bell) \b backspace \c suppress trailing new line \n new line \r carriage return \t horizontal tab \\ backslash For e.g. $ echo -e "An apple a day keeps away \a\t\tdoctor\n"For e.g. $ echo -e "An apple a day keeps away \a\t\tdoctor\n" © Prepared By: Razif Razali 10

More about Quotes There are three types of quotesThere are three types of quotes © Prepared By: Razif Razali 11 QuotesNameMeaning " Double Quotes "Double Quotes" - Anything enclose in double quotes removed meaning of that characters (except \ and $). ' Single quotes 'Single quotes' - Enclosed in single quotes remains unchanged. ` Back quote`Back quote` - To execute command Example: $ echo "Today is date" Can't print message with today's date. $ echo "Today is `date`". It will print today's date as, Today is Tue Jan

Exercise Write a script to display the following output in my_scripttwo file.Write a script to display the following output in my_scripttwo file. © Prepared By: Razif Razali 12