Miscellaneous

  Home arrow Miscellaneous arrow Page 4 - In Detail: UNIX File Systems
MISCELLANEOUS

In Detail: UNIX File Systems
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2009-04-01

    Table of Contents:
  • In Detail: UNIX File Systems
  • Mounting file systems
  • Links in UNIX
  • The standard files and directions
  • File names on the shell command line

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    In Detail: UNIX File Systems - The standard files and directions


    (Page 4 of 5 )

     

    They are three standard files: stdin, stdout and stderr. These files are for input, output and the error echo, respectively. Every application will maintain these files. Furthermore, it is a generally accepted fact that new programs should be written such that, by default, if we do not give to it an input they will read from the stdin, print on the stdout and signal errors on the stderr. 

    We call all the programs that follow this idea "filters." An integer number also codes to this tree inputs that are automatically opened by the operating system. The standard input is zero, the standard output is one and the standard error is two.  

    The shell allows you to change where files put their input and output. It can direct some files to a program as input or direct its output to a file. For input, use the > followed by the file name. For output we direct in the other direction, and use the > character followed by the file name.  

    These three standard files do not have names yet; so we can reach them, they exist via the /dev/stdin, /dev/stdout and /dev/stderr devices. Redirecting via these will also create a new file and add it to the output. To avoid this, and just append the new data to the end of a file, use the >>.  

    I will use this moment to also introduce the cat command. This will echo back the content of a file you point to it. This is a filter. If you use it with no arguments, it will use the stdin (the terminal itself) until you signal the end of file (Ctrl + D). After this, it will print back whatever you entered.  

    #print back the content of alfa

    cat alfa

     

    #use as input the alfa and as output the beta

    cat <alfa >beta

     

    # now we will append the content of alfa to beta

    cat <alfa >>beta

     

    #input alfa, output remains default, error to null device

    cat 0<alfa 2>/dev/null

    The last one is a little more interesting. This shows that we can also point something to direct to somewhere. We use the integer codification of the standard files as I described above. Also note that by directing the error output to the null device, we virtually ignore them, as the null device will eat up everything you throw at it. 

    More Miscellaneous Articles
    More By Gabor Bernat

    blog comments powered by Disqus

    MISCELLANEOUS ARTICLES

    - Oracle Database XE: Indexes and Sequences
    - Modifying Tables in Oracle Database XE
    - Oracle Database XE: Tables and Constraints
    - More on Oracle Databases and Datatypes
    - Oracle Database XE Datatypes: Datetime and L...
    - Oracle Database XE Datatypes: Character and ...
    - From Databases to Datatypes
    - Firefox 3.6.6 Released with Improved Plug-in...
    - Attention Bloggers: WordPress 3.0 Now Releas...
    - Reflection in PHP 5
    - Inheritance and Other Advanced OOP Features
    - Advanced OOP Features
    - Linux from Scratch V.6.6 Review
    - Linux Gaining in Strength
    - Install Slackware on Your Old PC


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap