.Dd Created:2026-03-27|Updated:2026-03-27| .de ocsi \\$* , .. .de oxr .ocsi .Xr \\$* .. .de oit .It \\$* .. .de obdi .Bl -dash -compact .oit \\$* .. .de obdl .Bd -literal -compact \\$* .. .de onote .Bl -hang -compact .oit \\$* .El .. .de ocomm .Bl -diag -compact .oit \\$* .El .. .de opsy .Pp .Sy - \\$* .. .de obc .Bl -column \\$* .. .de obc2 .obc opt desc .. .de obc3 .obc option arguments description .. .nr r 0 .ie ( \nr == 1 ) \{\ .de dm .opsy OpenBSD manpages: \\$* .. .\} .ie ( \nr == 0 ) \{\ .de dm .opsy Archlinux manpages: \\$* .. .\} .Dt BASH oh .Os linux , OpenBSD 7.8 | .Nm bash .Nd usage, redirection and tips. .Sh REDIRECTION Commands can output to files or programs. .Ss Files .obc2 .It Overwrite file Ta : Li ls > log .It Append to file Ta : Li ls >> log .El .Ss File descriptors Command results can: .obdi be displayed on the terminal: stdout, file descriptor 1. .oit be an error: stderr, file descriptor 2. .El When redirecting, only the output is sent, to add error, stderr must be added to stdout: .Dl ls > log 2>\*(Am1 This redirects stderr(2) to stdout(\*(Am1) and the output is saved to log. \*(Am1 means 1 is a file descriptor, not a file. .Sh CHAINED COMMANDS Commands can be combined: .obc2 .It Sequential execution Ta : Li command1 \&; command2 .It Execute command2 if command1 was successful Ta : Li command1 \*(Am\*(Am command2 .It Execute command2 if command1 failed Ta : Li command1 || command2 .El .Sh SUBSHELL Commands can be grouped and redirected together. .Dl \&( command1 \*(Am\*(Am command2 \&) >> log 2>\*(Am1 .Sh SEE ALSO .Xr linux oh .dm .Xr bash 1 .Sh AUTHORS .An -nosplit .Xr ohazot oh | .Xr about oh | .Lk https://ohazot.com ohazot.com .Aq Mt admin@ohazot.com