Linux: stderr bash ?

Posted on 2012-08-23
Last Modified: 2012-08-23
echo "wrong" >> Stderr

Is this the way to redirect to Stderr? Is this correct?

Thank you!
Question by:g0all
    LVL 68

    Accepted Solution

    Standard error is traditionally bound to file descriptor 2, in shell terms "&2"

    So writing output to stderr looks like this:

    echo "wrong" >&2

    If you put the above in a script, let's say "myscript" and run

    myscript 2>/dev/null

    you will see nothing on your terminal, because the output you wrote to stderr gets redirected to /dev/null this way.
    LVL 1

    Author Closing Comment

    Thanks wmp!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now