linux-command redirection-symbol input/output-file-name
There are three basic redirection operators.
- output (>)
ex: $ ls > dirList.txt
the output of the ls command will write in dirList.txt if the file is already present then it will be overwritten without any warning. - append (>>)
To output Linux-commands result to the end of file (append). Note that if file exist , it will be opened and new information will be written to end of file, without losing previous information, And if file is not exist, then new file is created. For e.g. To send output of pstree command to already exist file give command
ex: $ pstree >> processList.txt - input (<) To take input to Linux-command from file instead of key-board. If file does not exist then you have to give using key-board. ex: ./a.out < input.in
File Name | Discriptor | Use | Example |
Stdin | 0 | Standard Input | Keyboard |
Stdout | 1 | Standard Output | Screen |
Stderr | 2 | Standard Error | Screen |