Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Linux Bourne Again Shell (BASh) Programming  VSRivera IBM Learning Services Worldwide Certified Manual
Objectives <ul><li>To understand the use and application of redirections </li></ul><ul><ul><li>Output </li></ul></ul><ul><...
<ul><li>Every process has file descriptor table asscociated with it </li></ul><ul><li>File descriptors can be defined from...
File Descriptor table . . User-defined 3 . User-defined Standard error - screen 2> Default Standard out - screen 1> Defaul...
Redirection <ul><li>Input Redirection </li></ul><ul><ul><li>Redirecting standard input from a file </li></ul></ul><ul><ul>...
Redirection <ul><li>Output appending </li></ul><ul><ul><li>Appending standard output to a file </li></ul></ul><ul><ul><li>...
Examples <ul><li>cat > names </li></ul><ul><li>cat < names </li></ul><ul><li>ls –la > directory </li></ul><ul><li>ls –la d...
Association <ul><li>File descriptors can be joined, so that they output to the same place </li></ul><ul><ul><li>Command > ...
Examples <ul><li>cat names.txt 2>&1  </li></ul><ul><li>ls –la names.txt 1>&2 </li></ul><ul><li>cat < names 2>&1 >/dev/null...
<ul><li>Question? </li></ul>
Upcoming SlideShare
Loading in …5
×

COMELEC III - Bash unit 1 part 2

380 views

Published on

Published in: Technology, Lifestyle
  • Be the first to comment

  • Be the first to like this

COMELEC III - Bash unit 1 part 2

  1. 1. Linux Bourne Again Shell (BASh) Programming VSRivera IBM Learning Services Worldwide Certified Manual
  2. 2. Objectives <ul><li>To understand the use and application of redirections </li></ul><ul><ul><li>Output </li></ul></ul><ul><ul><li>Input </li></ul></ul><ul><ul><li>Append </li></ul></ul><ul><ul><li>Association </li></ul></ul>
  3. 3. <ul><li>Every process has file descriptor table asscociated with it </li></ul><ul><li>File descriptors can be defined from 3 onwards. </li></ul><ul><li>/dev/tty always refers to keyboard </li></ul>Process I/O Process Input (0) Error (2) Output (1)
  4. 4. File Descriptor table . . User-defined 3 . User-defined Standard error - screen 2> Default Standard out - screen 1> Default Standard in - keyboard 0< Default
  5. 5. Redirection <ul><li>Input Redirection </li></ul><ul><ul><li>Redirecting standard input from a file </li></ul></ul><ul><ul><li>Command < filename </li></ul></ul><ul><li>Output Redirection </li></ul><ul><ul><li>Redirecting standard output to a file </li></ul></ul><ul><ul><li>Command > filename </li></ul></ul><ul><ul><li>Redirecting standard output to a file </li></ul></ul><ul><ul><li>Command 2> filename </li></ul></ul>
  6. 6. Redirection <ul><li>Output appending </li></ul><ul><ul><li>Appending standard output to a file </li></ul></ul><ul><ul><li>Command >> filename </li></ul></ul><ul><ul><li>Appending standard error to a file </li></ul></ul><ul><ul><li>Command 2>> filename </li></ul></ul>
  7. 7. Examples <ul><li>cat > names </li></ul><ul><li>cat < names </li></ul><ul><li>ls –la > directory </li></ul><ul><li>ls –la dir 2> error.txt to error.txt </li></ul><ul><li>cat dir 2>> error.txt </li></ul><ul><li>cp names{.txt,.bak} 2> err_com.txt </li></ul><ul><li>cp names{.txt,.bak} 2> /dev/null </li></ul><ul><li>cat names > /dev/lp0 2>err.txt </li></ul><ul><li>wc < names > count.txt </li></ul>
  8. 8. Association <ul><li>File descriptors can be joined, so that they output to the same place </li></ul><ul><ul><li>Command > file 2>&1 </li></ul></ul><ul><ul><li>Redirects standard error to join with standard out </li></ul></ul>Process Input (0) Error (2) Output (1)
  9. 9. Examples <ul><li>cat names.txt 2>&1 </li></ul><ul><li>ls –la names.txt 1>&2 </li></ul><ul><li>cat < names 2>&1 >/dev/null </li></ul><ul><li>cat names.txt 2>&1>names.bak </li></ul><ul><li>ls –la names.txt 1>&2>error.bak </li></ul>
  10. 10. <ul><li>Question? </li></ul>

×