_ _ ___ | |__ __ _ _______ | |_ / _ \| '_ \ / _` |_ / _ \| __| | (_) | | | | (_| |/ / (_) | |_ \___/|_| |_|\__,_/___\___/ \__|
| ohazot | docs | links | dev | conf | txt |
| es | en |
| mdoc file |
| search |
bash —
usage, redirection and tips.
REDIRECTION
Commands can output to files or programs.
Files
| Overwrite file | : ls > log |
| Append to file | : ls >> log |
File descriptors
Command results can:
- be displayed on the terminal: stdout, file descriptor 1.
- be an error: stderr, file descriptor 2.
ls > log 2>&1CHAINED COMMANDS
Commands can be combined:
| Sequential execution | : command1 ; command2 |
| Execute command2 if command1 was successful | : command1 && command2 |
| Execute command2 if command1 failed | : command1 || command2 |
SUBSHELL
Commands can be grouped and redirected together.
( command1 && command2 )
>> log 2>&1SEE ALSO
- Archlinux manpages: bash(1)