Redirection of output and input in unix/linux

  • 1,237 views
Uploaded on

It will guide you how to use redirection in unix/linux and comparison of shell type

It will guide you how to use redirection in unix/linux and comparison of shell type

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,237
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
17
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Created by
  • 2. Topics
    SHELL
    1
    • Different types of shell
    • 3. Summary of shell features
    • 4. Configuration files for shells
    REDIRECTION OF INPUT AND OUTPUT
    2
    • Redirect descriptor
    • 5. Redirect usage
  • 1
    2
    Different types of shell
    Shell
    Path
    Description
    OS
    Bourne
    /bin/sh
    This is the original Unix shell written by Steve Bourne of Bell Labs. It is available on all UNIX systems.
    All unix
    Korn
    /bin/ksh
    This shell was written by David Korn of Bell labs. It is now provided as the standard shell on Unix systems.
    AIX
    C
    /bin/csh
    This shell was written at the University of California, Berkeley.
    It provides a C-like language with which to write shell script.
    BSD
    TC
    /bin/tcsh
    This shell is available in the public domain.
    It provides all the features of the C shell together with emacs style editing of the command line.
    MAC OSX
    Bash
    /bin/bash
    This is a public domain shell written by the Free Software Foundation under their GNU initiative.
    Ubuntu, Centos
    Reference: http://unixhelp.ed.ac.uk/shell/oview2.html
  • 6. Topics
    SHELL
    1
    • Different types of shell
    • 7. Summary of shell features
    • 8. Configuration files for shells
    REDIRECTION OF INPUT AND OUTPUT
    2
    • Redirect descriptor
    • 9. Redirect usage
  • 1
    2
    Summary of shell features
    Bourne
    C
    TC
    Korn
    Bash
    Command history
    no
    yes
    yes
    yes
    yes
    Command alias
    no
    yes
    yes
    yes
    yes
    Shell scripts
    yes
    yes
    yes
    yes
    yes
    Filename completion
    no
    yes*
    yes
    yes*
    yes
    Command line editing
    no
    no
    yes
    yes*
    yes
    Job control
    no
    yes
    yes
    yes
    yes
    * Not the default setting for this shell.
    Reference: http://unixhelp.ed.ac.uk/shell/oview1.1.html
  • 10. Topics
    SHELL
    1
    • Different types of shell
    • 11. Summary of shell features
    • 12. Configuration files for shells
    REDIRECTION OF INPUT AND OUTPUT
    2
    • Redirect descriptor
    • 13. Redirect usage
  • 1
    2
    Configuration files for shells
    sh
    ksh
    csh
    tcsh
    bash
    /etc/.login
    login
    login
    /etc/csh.cshrc
    yes
    yes
    /etc/csh.login
    login
    login
    ~/.tcshrc
    yes
    ~/.cshrc
    yes
    yes
    ~/.login
    login
    login
    ~/.logout
    login
    login
    /etc/profile
    login
    login
    login
    ~/.profile
    login
    login
    login
    ~/.bash_profile
    login
    ~/.bash_login
    login
    ~/.bash_logout
    login
    ~/.bashrc
    int. + n/login
    blank means a file is not read by a shell at all.
    "yes" means a file is always read by a shell upon startup.
    "login" means a file is read if the shell is a login shell.
    "n/login" means a file is read if the shell is not a login shell.
    "int." means a file is read if the shell is interactive.
    Reference: http://en.wikipedia.org/wiki/Unix_shell
  • 14. Topics
    SHELL
    1
    • Different types of shell
    • 15. Summary of shell features
    • 16. Configuration files for shells
    REDIRECTION OF INPUT AND OUTPUT
    2
    • Redirect descriptor
    • 17. Redirect usage
  • 1
    2
    Redirect descriptor
    Descriptor
    Description
    0
    Standard Input (Generally Keyboard)
    1
    Standard output (Generally Display/Screen)
    2
    Standard Error Ouput (Generally Display/Screen)
    >
    Redirect standard output
    2>
    Redirect standard error
    2>&1
    Redirect standard error to standard output
    <
    Redirect standard input from
    >>
    Append to standard output
    &
    Run as background process
  • 18. Topics
    SHELL
    1
    • Different types of shell
    • 19. Summary of shell features
    • 20. Configuration files for shells
    REDIRECTION OF INPUT AND OUTPUT
    2
    • Redirect descriptor
    • 21. Redirect usage
  • 1
    2
    Redirect usage
    Let me write the example about how to use redirection in various purpose.
    Redirect standard output to a file
    #!/bin/bash
    /home/panu/start-application1.sh > file
    Append standard output to a file
    #!/bin/bash
    /home/panu/start-application1.sh >> file
    Redirect standard input from file
    #!/bin/bash
    /home/panu/start-application1.sh < file
    Redirect standard output to “std_out.log” and redirect standard error to “std_error.log”
    #!/bin/bash
    /home/panu/start-application1.sh > std_out.log  2> std_err.log
    Redirect standard error to standard output “std_out_err.log”
    #!/bin/bash
    /home/panu/start-application1.sh > std_out_err.log  2>&1
  • 22. Thank you for watching
    my presentation
    Created by
    panuausavasereelert
    blog: http://panu.in.th
    email: panu@panu.in.th
    twitter: @panuinth