Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt

Use this file to discover all available pages before exploring further.

The &>> operator is a Bash-specific redirection control operator that appends both standard output (stdout, file descriptor 1) and standard error (stderr, file descriptor 2) from a command to a specified file. Introduced in Bash 4.0, it serves as a syntactic shorthand for redirecting both output streams without truncating the target file.

Syntax

command &>> filename

Mechanics

When the Bash shell parses the &>> token, it performs the following operations:
  1. It opens the target filename in append mode (O_WRONLY | O_CREAT | O_APPEND). If the file does not exist, it is created.
  2. It binds file descriptor 1 (stdout) to this file.
  3. It binds file descriptor 2 (stderr) to the exact same file description as file descriptor 1.
Because both streams are redirected in append mode, the existing contents of the target file are preserved, and new output from either stream is written to the end of the file.

POSIX Equivalent

The &>> operator is not POSIX-compliant. Under the hood, it is functionally identical to the traditional, POSIX-compliant two-step redirection syntax:

# Bash 4.0+ shorthand
command &>> filename


# POSIX-compliant equivalent
command >> filename 2>&1
In the POSIX equivalent, the order of operations is strictly evaluated from left to right:
  1. >> filename redirects stdout (FD 1) to append to filename.
  2. 2>&1 duplicates file descriptor 1, pointing stderr (FD 2) to the same open file handle that FD 1 is currently using.

Compatibility

Because &>> is a Bash extension (specifically Bash 4.0 and newer), it will result in a syntax error or unexpected behavior if executed in a strict POSIX shell (like sh, dash, or Alpine Linux’s default shell) or in older versions of Bash (such as the default Bash 3.2 found on macOS). In environments requiring strict portability, the >> filename 2>&1 syntax must be used instead.
Master Bash with Deep Grasping Methodology!Learn More