140 likes | 279 Views
Redirection & Pipes. Understanding UNIX Input and Output. What is Input?. Information fed into a data processing system or computer (Merriam-Webster Dictionary) Data necessary to create some action or output. Text ‘Hello World’ Keystroke combinations CTRL -D. Input Sources.
E N D
Redirection & Pipes Understanding UNIX Input and Output
What is Input? • Information fed into a data processing system or computer (Merriam-Webster Dictionary) • Data necessary to create some action or output. • Text • ‘Hello World’ • Keystroke combinations • CTRL -D
Input Sources • Standard Input (stdin) Device • That part of the operating system controlling from where a program receives its input. • keyboard • Any defined device capable of receiving input
What is Output? • The information produced by a computer (Merriam-Webster Dictionary) • Data created as a result of some action or input. • Text • ‘Hello World’ • Pictures & Graphics • …
Output Destinations • Standard Output (stdout) Devices • That part of the operating system that controls where a program writes its output. • Monitor • Printer • Any defined device capable of receiving output
What is a file? • UNIX is a file based operating system • Everything is a file • Say What!?
UNIX File Types • Types of files • Directory File • Contains references to other files • /dev • Regular File • Text, configuration, etc. • /home/my.txt • Device Files • /dev/cdrom
UNIX Commands • Are commands Files too • Typically single “specialized” functions • Commands are files that accept input and perform some operation, either • On the input directly, or • # cat my.txt • As directed by the input. • # ls –al /usr
Redirection • Where? • > the redirection operator • Allows for an output destination other then standard output (stdout). • Is a write only operation • Can only redirect to regular files. • # ls –al /usr > directory.lst
Pipes • Keeping the Flow Going… • | the pipe operator • Allows for the output (stdout) of one command to serve as the input (stdin) of another command • No write involved in the process • Can only be used with commands (executables) • # ls –al /usr/bin | grep ls -
Putting it All Together • What do we gain • Extended functionality • Increased control • Innovative solutions • An understanding of both input and output
IN CLASS DEMONSTRATION • SIX Volunteers able to follow instructions • Hmmmm… • A paper | B | C | D | E | F > Frontdesk