TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
>> operator is a Bash redirection control operator used to append the output of a command to a file. Unlike the > operator, which truncates the target file before writing, >> instructs the shell to open the target file in append mode (using the O_APPEND system flag). This ensures that existing data is preserved and new data is written strictly to the end of the file.
If the specified target file does not exist, the shell creates it, subject to the current umask settings.
Syntax and File Descriptors
In Bash, redirection operators interact directly with File Descriptors (FDs). The general syntax is[n]>>word, where n is an optional file descriptor (which can be multi-digit) and word is the target file path. If n is omitted, Bash defaults to FD 1 (Standard Output, or stdout).
Additionally, Bash supports dynamic file descriptor allocation using the {varname}>>word syntax. This instructs the shell to automatically find an available file descriptor (typically 10 or higher) and assign its integer value to the specified variable.
Redirection Order and Chaining
When managing multiple file descriptors, the order of redirection evaluation is strictly left-to-right. To append bothstdout and stderr to the same file in older POSIX-compliant shells (prior to the introduction of &>>), file descriptor duplication is required:
Technical Characteristics
- Atomicity: Because
>>utilizes theO_APPENDsystem flag, the operating system guarantees that the file offset is updated atomically to the end of the file before every write operation occurs. This behavior is governed by the OS filesystem implementation andwrite()system call semantics. This prevents data corruption or interleaved characters when multiple processes append to the same regular file concurrently. - Interaction with
noclobber: The Bash shell optionset -o noclobber(orset -C), which prevents the>operator from overwriting existing files, has no effect on the>>operator. Because>>is inherently non-destructive to existing content, the shell permits its execution regardless of thenoclobberstate. - Expansion: The
word(target file) following the>>operator is subject to brace expansion, tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, quote removal, pathname expansion, and word splitting. If the expansion results in more than one word, Bash will throw an ambiguous redirect error.
Master Bash with Deep Grasping Methodology!Learn More





