- No.
- 26
- Date
- Learning goal
- Terminal Start, lesson 11
- Level
- 3 of 3
Command of the day No. 26: 2>&1 and /dev/null
Purpose: Moves error messages elsewhere or makes them vanish.
Syntax: command 2>/dev/null, command 2>&1
Example:
ls todo.txt missing.txt
ls: cannot access 'missing.txt': No such file or directory
todo.txt
ls todo.txt missing.txt 2>/dev/null
todo.txt
ls missing.txt 2>&1 | wc -l
1 Output from the simulator, as on a real Linux.
Options:
Try it in the terminal Share image
Fills in the command. Nothing runs until you press Enter.