• Redirecting Input /Output

    Redirecting Input /Output

    The standard Output of command , which normally display on the terminal can be redirected into a file. Similarly standard error, which normally display on the terminal can be redirected into a file.

    Common redirection operator

    > : command>file : output command to file

    >> : command>>file : Append output of command to file

    < : command>file : receive input from file

    2> : command2>file : error from command to file

    2>> : command2>>file : append

    Example:

    #find /etc –name passwd

    this command will search for all file name passwd in /etc and its subdirectories

    now we can redirtect the standard outpout

    #find /etc –name passwd > output

    output is a file where command output will be stored. Standard error is still displayed on the screen

    #cat output

    If the target file of the file redirection with > already exists, the existing file will be overwritten. To append data to an existing file use >> to redirect instead of >

    #find /etc –name passwd >> output

    Redirecting standard Error

    We can redirect standard error with 2>

    #find /etc –name passwd 2>errorfile

    standard output is displayed on the screen , redirect further standard error, appending to the same file with 2>>

    #find /etc/ -name passwd 2>>errorfile

    #cat errorfile

0 comments:

Leave a Reply

.

FEEDS FROM THIS BLOG

FEEDJIT Live Traffic Feed

My Zimbio   Blog Directory - OnToplist.com   Red Hat Enterprice Linux RHCE RHCT RHCA RHCSS  Powered by  MyPagerank.Net  Academic blogs & blog posts   BlogRankers.com  TopOfBlogs  BuzzCritic     Academics  Blog Directory  Hihera.com  Technology Blogs - Blog Rankings   Visit blogadda.com to discover Indian blogs  Academics Blogs  Computers (Linux) - TOP.ORG    Rallyshare    Yahoo bot last visit powered by MyPagerank.Net     The Weblog Review  blogarama - the blog directory  SEO services    Academic blogs & blog posts