More Command Line Options Pipes, Redirection, Standard files Copyright © 2015 Curt Hill.

Slides:



Advertisements
Similar presentations
Computer Basics 2.
Advertisements

Lab 9 CIS 370 Umass Dartmouth.  A pipe is typically used as a one-way communications channel which couples one related process to another.  UNIX deals.
Programming In C++ Spring Semester 2013 Lecture 8 Programming In C++, Lecture 8 By Umer Rana.
UNIX Chapter 12 Redirection and Piping Mr. Mohammad Smirat.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
HD44780 LCD programming From the Hardware Side Design and implementation details on the way to a valid SPI-LCD interface driver.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Chapter 11 UNIX Printing. have to be root to setup a printer local printer is directly connected remote printer is a network printer print queue is nothing.
School of Computing Science CMT1000 © Ed Currie Middlesex University Lecture 11: 1 CMT1000: Introduction to Programming Ed Currie Lecture 10: File Input.
Chapter 7 Advanced Directory and File Management.
Spring 2007Introduction to OS1 IT 3423: Operating System Concepts and Administration Instructor: Wayne (Weizheng) Zhou
The Operating System and the User Interface
UNIX chapter 03 Getting Started Mr. Mohammad Smirat.
Cambodia-India Entrepreneurship Development Centre - : :.... :-:-
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.
Unix Filters Text processing utilities. Filters Filter commands – Unix commands that serve dual purposes: –standalone –used with other commands and pipes.
Operating Systems Chapter 4.
Chapter 4: UNIX File Processing Input and Output.
MCB Lecture #3 Sept 2/14 Intro to UNIX terminal.
The Operating System. without an operating system: the screen would be blank there'd be no response when you tap the keys disk programmes wouldn't load.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
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.
Ch 21 Command Syntax Using the DIR Command with Parameters and Wildcards.
Standard Grade Computing System Software & Operating Systems.
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.
Unix Basics Chapter 4.
RjpSystem Level Programming Operating Systems 1 Having fun withy the Unix Operating System Praxis Week 7 Rob Pooley.
Advanced UNIX Shell Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
CENT 305 Information Systems Security Linux Introduction.
Title Slide CSS 404/504 The UNIX Operating System (2) By Ralph B. Bisland, Jr.
Sed sed is a program used for editing data. It stands for stream editor. Unlike ed, sed cannot be used interactively. However, its commands are similar.
The Command Line Mostly MS Dos with some UNIX/LINUX Copyright © Curt Hill.
Pipes and Filters Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
I/O and Redirection. Standard I/O u Standard Output (stdout) –default place to which programs write u Standard Input (stdin) –default place from which.
Operating Systems Concepts 1/e Ruth Watson Chapter 3 Chapter 3 DOS Ruth Watson.
Introduction to UNIX Geraint Vaughan. What is UNIX? Command-line operating system (not point- and click) Designed for ‘experts’ Lots of different variants.
Copyright © Curt Hill Joins Revisited What is there beyond Natural Joins?
Using Commands Introduction to Unix May 24, 2008 Rabat, Morocco Hervey Allen.
Introduction to Programming Using C An Introduction to Operating Systems.
Shell Scripting – Putting it All Together. Agenda Escaping Characters Wildcards Redirecting Output Chaining and Conditional Chaining Unnamed and Named.
Week 9 - Nov 7, Week 9 Agenda I/O redirection I/O redirection pipe pipe tee tee.
Page 1 Printing & Terminal Services Lecture 8 Hassan Shuja 11/16/2004.
Agenda Positional Parameters / Continued... Command Substitution Bourne Shell / Bash Shell / Korn Shell Mathematical Expressions Bourne Shell / Bash Shell.
Web Services An Introduction Copyright © Curt Hill.
Small Office Home Office
Scanner Generation Using SLK and Flex++ Followed by a Demo Copyright © 2015 Curt Hill.
Batch Files Weaker form of UNIX shell scripts. Introduction UNIX may use one of several shells The shell is the command interpreter It interacts with.
Batch Files Weaker form of UNIX shell scripts Copyright © by Curt Hill.
Copyright © 2007 by Curt Hill Interrupts How the system responds.
Command Prompt Chapter 9 Pipes, Filters, and Redirection ©Richard Goldman 11/30/2000 Revised 10/16/2001.
© Prepared By: Razif Razali 1 TMK 265: UNIX SYSTEM CHAPTER FOUR – QUOTING IN DETAIL.
Uniq The uniq command is useful when you need to find duplicate lines in a file. The basic format of the command is uniq in_file out_file In this format,
CHARACTER INPUT / OUTPUT AND INPUT VALIDATION. Introduction Input and output devices: keyboards, disk drives, mouse, monitors, printers. I/O functions.
Batch Files Flow of Control to Strengthen Copyright © by Curt Hill.
Copyright © 2005 – Curt Hill MicroProgramming Programming at a different level.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
Compare Programs What do they need to do to be helpful? Copyright © 2016 Curt Hill.
Batch Files More flow of control Copyright © by Curt Hill.
System SOFTWARE.
Mostly MS Dos with some UNIX/LINUX
Documentation Generators
Chapter 6 Filters.
Shell Commands Using BASH Copyright © 2017 Curt Hill.
Compilers, Make and SubVersion
A poorly named Curt Hill utility program
Intro to Ethical Hacking
UNIX File System Go Climb a Tree Weiyu Zhang (96142)
UNIX/LINUX Commands Using BASH Copyright © 2017 – Curt Hill.
Cmdlets “Command-lets”
HD44780 LCD programming From the Hardware Side
Presentation transcript:

More Command Line Options Pipes, Redirection, Standard files Copyright © 2015 Curt Hill

Introduction These are two features pioneered by UNIX and then partially copied in DOS A pipe is a connector of the output of one program to the input of another Redirection is changing the where the input of a program comes from or the output goes to Copyright © 2015 Curt Hillout

Redirection The idea of file redirection is an instance of device independence We want our files to be independent of the type of device Redirection mainly applies to the standard input, output and error files Not every command allows redirection, but most of the standard ones do Copyright © 2015 Curt Hill

Output Redirection Output redirection use the > preceding the new file Thus the command: copy *.dat *.txt >results.lst –will do the copy as always but the copy output will be in the results.lst file –Copy output is the names of the files copied and a count Copyright © 2015 Curt Hill

Other Redirections Somewhat less common, because most DOS commands take no input –They know everything they need from the command line parameters The input redirection character is < followed by the file The error redirection is >> followed by the file Copyright © 2015 Curt Hill

Standard Files DOS had several standard file specifications These included lpt1: lpt2: nul: among others These substituted for a normal file name specification Thus: copy xyz.dat lpt1: prints the file Copyright © 2015 Curt Hill

Standard Files The files lpt1: lpt2: lpt3: only word if this is an attached file –Not a network printer Thus most of the standard files are not used much any more Only the nul: is of much value –The : may be left out Silencing a copy: copy a*.dat *.txt >nul –does the copy but nothing sent to console Copyright © 2015 Curt Hill

Pipes Once we can redirect standard input and output then pipes are easy A pipe is just a temporary file that connects two programs The character is | and should be put between two programs The OS provides a temporary file –The first program places its standard output in the file –The second program reads its standard input from the file –The file is then deleted Copyright © 2015 Curt Hill

Example Assume abc and def are both programs abc | def The abc program sends its standard output to an OS supplied temporary file The def program reads it from there This leads us to the concept of a filter Copyright © 2015 Curt Hill

Filters Much more common on UNIX than DOS A filter takes some data from standard input It transforms it in some way It writes it to standard output Copyright © 2015 Curt Hill

Example A common filter on UNIX was lc –It prefixed each line with the current line number Suppose that program mon produces a lot of output then: mon | lc >mon.out –will prefix line numbers and save in a file Copyright © 2015 Curt Hill

Finally Pipes and redirection were very important in the UNIX environment –Especially before the GUI era They were not as important in the DOS world –It was not automatic to write a program to use them –They are still handy Copyright © 2015 Curt Hill