JAVA SCRIPT

RH033 6. STANDARD INPUT/OUTPUT AND ERROR REDIRECTION

1. Input redirection ( < ) 
  cat < file1    --> Display contents of file...  Lets  say contents of  file1 is    LYNUX  LYNUX LYNUX.  And i can replace  letter  Y with I using  "tr" command...

 tr 'Y'   'I'     < file1   > file2 
 Replaces  Y with I  of  File1 and store the new  replaced text to File 2...



2. Ouptput redirection (>) //output can be redirected to file or terminal

     cal > file3       -->redirect output to file
     cal > /dev/tty3   -->redirect output third terminal

3. Error redirection (2>)
 
     cal 222222    2>  file4     -->Put error to file 4
     tr 'a' 'A' file2   2> file5 -->Put error to file5

 
4.  pipe (|) =Used to combine two related commands, output of first
    


      cal 2009 |less                       
                //   command is taken as input to second command
      cat /etc/passwd | cat -n
      ps -au |grep tty2
     
 
5.   Tee = Creates new file and stores previous commands output

       cat a|tee b|sort|tee c|cat -n|tee d



No comments:

Post a Comment