
Redirecting input from something other than a standard input device such as the keyboard, for example from a file, is called input redirection, and
saving things that would be printed on the screen, such as a command's output or an error message, to a file or similar is called output redirection.
I/O redirection is written with <,>. In front of <,> you write the fd number that means how the program will use I/O. In this case you must write <,> directly against the fd number, with no space.
| fd | Name | Purpose | Standard device |
|---|---|---|---|
| 0 | stdin | Holds what will be passed as input to the command | Keyboard |
| 1 | stdout | Holds what will be output from the command | Screen |
| 2 | stderr | Holds error messages output from the command | Screen |
| Form | Meaning |
|---|---|
| command fd-number < file | The command reads data from the redirected file rather than from the default file or the standard input device. |
| command fd-number > file | The command writes data to the redirected file rather than to the default file or the standard output device. |
※ When you use I/O redirection, you can usually omit the fd number in front of < and >.
※ Most shells provide basic redirection for stdin, stdout, and stderr.
Input redirection redirects the data to be processed so that it is read from another file or similar, instead of from a standard input device such as the keyboard, and uses <. 0 can be omitted, so in general you just use <.
< example
A command that converts uppercase letters to lowercase and prints them

Output redirection redirects a command's results so that they are stored and written to a file or similar, instead of being printed on a standard output device such as the screen, and uses >. 1 can be omitted, so in general you just use >.
> example
A command that prints the text you entered

※ Be careful: if a file with the same name already exists after >, the existing file is overwritten.
To append new content to the existing file, use >>.
※ If the file does not already exist, it is created, and later runs of the same command keep appending only the new content.
Error redirection redirects error output so that, when an error occurs while running a command, the error text that would be printed on a standard output device such as the screen is stored and written to a file or similar. You still use >, as with output redirection, but you must write the fd number 2 in front of the > symbol.
2> example
I added _ to an ls option to force an error.

※ Sometimes you need to redirect both output and error messages to the same file. In that case you can use >& to avoid repeating the command.
※ The fd number 1 in front of the >& symbol can be omitted, but the fd number after the >& symbol cannot be omitted.
Comments 0
A nickname and a password are required. The same password edits or deletes the comment later. Comments appear after a review.