≡ Menu

standard error

BASH Shell Redirect Output and Errors To /dev/null

How do I redirect output and errors to /dev/null under bash / sh shell scripting? How do I redirect the output of stderr to stdout, and then redirect this combined output to /dev/null device? In Unix, how do I redirect error messages to /dev/null?
[click to continue…]

BASH Shell: How To Redirect stderr To stdout ( redirect stderr to a File )

Q. How do I redirect stderr to stdout? How do I redirect stderr to a file?
[click to continue…]

Printing output of c program to a file in Linux

Q. I’ve written a small program that does something useful for me. I always get output on screen. Sometime I need to send output to a file. How do I print output of my program to a file w/o making any changes to code?

A. Bash shell (and many other modern UNIX shell) supports the concept of I/O redirection It allows you to redirect standard output (screen), standard error and standard input (keyboard) using the following syntax.
command > output.file
command < input.file command >& error-n-output.file

So to redirect output of your own C program just enter:
$ ./myprogr > output.txt
$ cat output.txt