Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ch 91 Pipes, Filters and Redirection. Ch 92 Overview Will use redirection to redirect standard input and standard output.

Similar presentations


Presentation on theme: "Ch 91 Pipes, Filters and Redirection. Ch 92 Overview Will use redirection to redirect standard input and standard output."— Presentation transcript:

1 Ch 91 Pipes, Filters and Redirection

2 Ch 92 Overview Will use redirection to redirect standard input and standard output.

3 Ch 93 Overview Learn how pipes can be used to connect programs.

4 Ch 94 Overview How filters can be used to manipulate data will be explained.

5 Ch 95 Overview What shell extensions are and how they may be used will be discussed.

6 Ch 96 Overview Learn how to combine commands using pipes, filters, and redirection.

7 Ch 97 Redirection of Standard I/O (Input/Output) Operating system gets information from or sends information to: è Standard input è Standard output è Standard error

8 Ch 98 Redirection of Standard I/O (Input/Output) Fig 9.1 Input and Output Devices p. 440

9 Ch 99 Redirection of Standard I/O (Input/Output) Not all commands deal with standard input/output.

10 Ch 910 Redirection of Standard I/O (Input/Output) Fig 9.2 Results of Copy Command p. 440

11 Ch 911 Redirection of Standard I/O (Input/Output) I/O redirection tells OS you want information read from or written to a device other than the standard ones.

12 Ch 912 Redirection of Standard I/O (Input/Output) Fig 9.3 Redirecting Standard Output p. 441

13 Ch 913 Redirection of Standard I/O (Input/Output) Symbols used for redirection: è > (greater than) è < (less than) è >> (double greater than)

14 Ch 914 Activity—Using > to Redirect Standard Output KEY CONCEPTS: è Redirection is either/or process è Redirection works with commands that write their results to standard output device (screen) è Using > è COPY can only copy files, not commands

15 Ch 915 Activity—Using < to Redirect Standard Input KEY CONCEPTS: è DEL*.* requires keyboard response è Using < è Any input from keyboard ignored if redirection of input is from a file

16 Ch 916 Activity—Using >> to Add Redirected Output to a File KEY CONCEPTS: è Using > between files - first file overwrites second file è Using >> between files - first file appended to end of second file

17 Ch 917 Filters Filter commands manipulate information.

18 Ch 918 Filters Three filter commands: è SORT è FIND è MORE

19 Ch 919 Filters Operating system creates temporary files while it “filters” data.

20 Ch 920 Filters Operating system will not be able to execute filter commands on write-protected disk.

21 Ch 921 The SORT Command SORT filter command: è Arranges lines of input in ascending order è Sends output to standard output unless redirected

22 Ch 922 The SORT Command SORT syntax: SORT [/R] [/+N] [/M kilobytes] [/L locale] [/REC recordbytes] [[drive:] [path1] filename1] [/T [drive2:] [path2]] [O [drive3:] [path3] filename3] Note: full syntax in Appendix H

23 Ch 923 Activity—Using SORT Fig 9.4 Filtering Data p. 448

24 Ch 924 Activity—Using SORT KEY CONCEPTS: è same as + Z è Numbers are numbers only when mathematical operation performed on them è Numbers often used as character data è Character data sorted from left to right è Numeric data sorted by units

25 Ch 925 Activity—Using SORT KEY CONCEPTS: è ASCII sort sequence order: å punctuation marks (including spaces) å numbers å letters (lowercase then uppercase )

26 Ch 926 Activity—Using SORT KEY CONCEPTS: è Sort sequence of BB, aa, #, 123, bb, 13, AA å # 123 13 aa AA bb BB è Sort sequence of “Carolyn Smith and Robert Nesler” åCarolyn Smith åRobert Nesler

27 Ch 927 Activity—Using SORT KEY CONCEPTS: è Can force OS to sort numbers correctly by using spacebar to add space characters è Using spaces forces lines to be same length - placing number digits in proper position è Left justify character data è Right justify numeric data

28 Ch 928 Filters and Redirection  Can redirect both output and input of filter commands.  Filter commands not usually used with keyboard input.

29 Ch 929 Activity—Using the SORT Command with Redirection KEY CONCEPTS: è / R - sorts in reverse or descending order è /+n - sorts by column number (character number) è /O - stores sorted data in a file (faster than redirection)

30 Ch 930 Activity—Using the SORT Command with Redirection KEY CONCEPTS: è In Windows XP Professional SORT does not require < prior to file being sorted è Column - On screen is place occupied by one character è Column number really means character number å + 17 - seventeenth position in list

31 Ch 931 The FIND Filter FIND filter command: è Allows you to search a file for a specific character string by enclosing it in quotation marks.

32 Ch 932 The FIND Filter FIND syntax: FIND [/V] [/C] [/N] [/I] [/OFF[LINE]]“string” [[drive:] [path] filename[ …]]

33 Ch 933 The FIND Filter FIND command is looking for exact match, therefore, is case sensitive unless /I parameter is used.

34 Ch 934 The FIND Filter FIND command at command line can help find a file based on content.

35 Ch 935 Activity—Using the FIND Filter KEY CONCEPTS: è With FIND must use double quotes è Character string must be enclosed in quotes è FIND is case sensitive

36 Ch 936 Activity—Using the FIND Filter KEY CONCEPTS: è FIND parameters: å/I - ignores case å/V - search a file for anything except what is in quotes å/N - finds specific line number of each occurrence å/C - numeric count of number of times specific character string appears in a file

37 Ch 937 Pipes Pipes: è Standard output of one program used as standard input to next program è Used with filter commands to further refine data è Not limited to two programs

38 Ch 938 Pipes è Pipe symbol is the vertical broken bar | and is used between two commands. è Location of the pipe symbol is not standard.

39 Ch 939 Pipes Fig 9.5 Piping Commands p. 457

40 Ch 940 Pipes Filter commands: è External commands è Read and write temporary files to disk will not work if a disk is write-protected.

41 Ch 941 Pipes All files must be named - even temporary ones.

42 Ch 942 The MORE Filter MORE filter: è Useful when reading long text file è Returns to system prompt when no more data in file è Can be both redirected and used with a pipe

43 Ch 943 The MORE Filter MORE syntax: MORE [/E [/C] [/P] [/S] [/Tn] [+n]] < [drive:] [path] filename command-name | MORE [/E [/C] [/P] [/S] [Tn] [+n] MORE /E [/C] [/P] [/S] [/Tn] [+n] [files]

44 Ch 944 The MORE Filter Extended features: P nDisplay next n lines S bSkip next n lines FDisplay next file QQuit =Show line number ?Show help line Display next page Display next line

45 Ch 945 Activity—Using the MORE Filter KEY CONCEPTS: è Locate pipe signal è Continued pressing of will return to system prompt è With extended features pressing Q will break command and return to system prompt è Can connect several commands with pipes and filters

46 Ch 946 Activity—Using the MORE Filter KEY CONCEPTS: è /P works only with DIR command è /P not a valid TYPE parameter è Records - lines of information in a data file è MORE allows you to view file at a specified line or record number è /C parameter clears the screen before each display

47 Ch 947 Other Features of MORE Bottom of the syntax diagram of MORE command: (Shown earlier) If extended features are enabled, the following commands are accepted at the –MORE– prompt: P nDisplay next n lines S nSkip next n lines FDisplay next file QQuit =Show line number ?Show help line Display next page Display next line

48 Ch 948 Other Features of MORE è Command prompt (default) enables shell extensions. è CMD /X - enables shell extensions. è CMD /Y - disables shell extensions.

49 Ch 949 Other Features of MORE Shell is the command interpreter used to pass commands to operating system.

50 Ch 950 Other Features of MORE è Commands that use shell extensions: DEL, COLOR, CD, MD, PROMPT, PUSHD, POPD, SET, SETLOCAL, ENDLOCAL, IF, FOR, CALL, SHIFT, GOTO, STARTS, ASSOC, and FTYPE. è Command name with /? gives full details as to what can be done with command.

51 Ch 951 Activity—Using the Extended Features of MORE KEY CONCEPTS: è Run remembers last command keyed in è /X - ensures ability to use extensions to commands è With extensions enabled results of keying in of keying in è Key in /Q - exit MORE command and return to system prompt

52 Ch 952 Activity—Using the Extended Features of MORE KEY CONCEPTS: è Key in /P - stops MORE - can request how many lines you want to display è = sign - displays which line number you are on è S - asked how many lines you want to skip in your display

53 Ch 953 Combining Commands with Pipes and Filters Use of pipe symbol: è Join commands (output from one command is input to next command) è Connect two or more programs and create a flow of data

54 Ch 954 Combining Commands with Pipes and Filters è When pipe symbol is used, there must be a command on both sides of the actual symbol. è If redirection used with “pipeline”, command does not have to be on either side of > or >>.

55 Ch 955 Combining Commands with Pipes and Filters è Redirecting output from a command is an “instead of” process. è Redirection becomes end of pipeline when you combine use of pipes and >.

56 Ch 956 Activity—Combining Commands KEY CONCEPTS: è Can search data to display only those lines/records that meet your requirements è If command sends output to screen can redirect output è Pipes åMust have command on either side of pipe åTaking standard output of command and using it as standard input to next command

57 Ch 957 Activity—Combining Commands KEY CONCEPTS: è Redirection å An “instead of” action å Only get one output place å Output goes to last place it is directed to go è Primary use of pipes and filters is to manipulate standard output/input of commands è Pipes/filters rarely used to sort or find data in text or data files


Download ppt "Ch 91 Pipes, Filters and Redirection. Ch 92 Overview Will use redirection to redirect standard input and standard output."

Similar presentations


Ads by Google