A. Bash and other modern shell provides I/O redirection facility. There are 3 default standard files (standard streams) open:
[a] stdin - Use to get input (keyboard) i.e. data going into a program.
[b] stdout - Use to write information (screen)
[c] stderr - Use to write error message (screen)
Understanding I/O streams numbers
The Unix / Linux standard I/O streams with numbers:Handle | Name | Description |
0 | stdin | Standard input |
1 | stdout | Standard output |
2 | stderr | Standard error |
Redirecting the standard error stream to a file
The following will redirect program error message to a file called error.log:$ program-name 2> error.log
$ command1 2> error.log
Redirecting the standard error (stderr) and stdout to file
Use the following syntax:$ command-name &>file
OR
$ command > file-name 2>&1
Another useful example:
# find /usr/home -name .profile 2>&1 | more
Redirect stderr to stdout
Use the command as follows:$ command-name 2>&1
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- My 10 UNIX Command Line Mistakes
- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
No comments:
Post a Comment