28
Chapter 12 Redirection and Pipes

Chapter 12

  • Upload
    belita

  • View
    19

  • Download
    0

Embed Size (px)

DESCRIPTION

Chapter 12. Redirection and Pipes. Figure 12.1  Standard files and file descriptors: (a) file descriptors (b) semantics of a command execution. Figure 12.2  Input redirection: (a) file descriptors and standard files for ‘command’ (b) semantics of input redirection. - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 12

Chapter 12

Redirection and Pipes

Page 2: Chapter 12

Figure 12.1  Standard files and file descriptors:(a) file descriptors(b) semantics of a command execution

Page 3: Chapter 12

Figure 12.2  Input redirection:(a) file descriptors and standard files for

‘command’(b) semantics of input redirection

Page 4: Chapter 12

Figure 12.3 Output redirection: (a) file descriptors and standard files for command’ (b) semantics of output redirection

Page 5: Chapter 12

Figure 12.3 Output redirection:(a) file descriptors and standard files for

‘command’(b) semantics of output redirection

Page 6: Chapter 12

Figure 12.4 Semantics of command run on remote server

rsh server sort < datafile

Page 7: Chapter 12

Figure 12.5  Combined use of input and output redirection

Page 8: Chapter 12

Figure 12.6  Error redirection:(a) file descriptors and standard files for

‘command’(b) semantics of error redirection

Page 9: Chapter 12

Figure 12.6  Error redirection:(a) file descriptors and standard files for

‘command’(b) semantics of error redirection

Page 10: Chapter 12

Figure 12.7  Error & Output redirection:cat lab1 lab2 lab3 1> cat.output 2> cat.errors

Page 11: Chapter 12

Figure 12.8 Error redirection:(a) file descriptors and standard files(b) semantics of the commands

cat lab1 lab2 lab3 1> cat.output.errors 2>&1 cat lab1 lab2 lab3 2> cat.output.errors 1>&2

Page 12: Chapter 12

Figure 12.8 Error redirection:(a) file descriptors and standard files(b) semantics of the commands

cat lab1 lab2 lab3 1> cat.output.errors 2>&1cat lab1 lab2 lab3 2> cat.output.errors 1>&2

Page 13: Chapter 12

Figure 12.9 Output and error redirection:(a) file descriptors and standard files for the cat command(b) standard files after cat lab1 lab2 lab3 2>&1

with no change in stdout and stderr(c) standard files after cat lab1 lab2 lab3 2>&1 1>

cat.output.errors(d) command semantics

Page 14: Chapter 12

Figure 12.9 Output and error redirection:(a) file descriptors and standard files for the cat command(b) standard files after cat lab1 lab2 lab3 2>&1

with no change in stdout and stderr(c) standard files after cat lab1 lab2 lab3 2>&1 1>

cat.output.errors(d) command semantics

Page 15: Chapter 12

Figure 12.10 Redirecting stdin, stdout, and stderr in a single command

Page 16: Chapter 12

Figure 12.11  The semantics of a pipeline with N commands

Page 17: Chapter 12

Figure 12.12  The semantics of the commandls -l | more command

Page 18: Chapter 12

Figure 12.13  The semantics of the commandgrep “John” < Students | lpr –Pspr

Page 19: Chapter 12

Figure 12.14  The semantics ofegrep ‘A$’ < ee446.grades | sort > ee446.As.sorted

Page 20: Chapter 12

Figure 12.15 The semantics of the commandrsh server cat ~/research/pvm/datafile.server | diff

datafile -

Page 21: Chapter 12

noclobber option

set -o noclobberDisables the overwriting of existing files

set +o noclobber• Disables the overwriting of existing files

Page 22: Chapter 12

tee Command

Syntaxtee [options] file-list

Reads input, echoes to stdin and all files in file-list

Page 23: Chapter 12

Figure 12.16  The semantics of the command cat names students | grep “John Doe” | tee file1

file2 | wc -l

Page 24: Chapter 12

Figure 12.17  Step-by-step semantics of the command

(find ~ -name foo -print > foo.paths) >& error.log

Page 25: Chapter 12

Figure 12.17  Step-by-step semantics of the command

(find ~ -name foo -print > foo.paths) >& error.log

Page 26: Chapter 12

Table 12.1 Redirection Operators and Their Meaning in Bash and TC Shells

Page 27: Chapter 12

Table 12.1 Redirection Operators and Their Meaning in Bash and TC Shells

Page 28: Chapter 12

Table 12.1 Redirection Operators and Their Meaning in Bash and TC Shells