Results for “redirect”
Small, practical examples. Search by task or narrow things down below.
Redirect an entire group of commands
Bash Scripts: Brace grouping runs in the current shell and shares a single output redirection.
Bash Scripts✓ Tested
Refuse to overwrite an existing file with redirection
Bash Scripts: Noclobber makes a plain greater-than redirection fail when the target already exists.
Bash Scripts✓ Tested
Capture standard output and standard error separately
Bash Scripts: Use distinct redirections when diagnostic text should not be mixed with data.
Bash Scripts✓ Tested
Compare two generated sorted streams
Bash Scripts: Process substitution lets a command consume another command’s output as a file-like input.
Bash Scripts✓ Tested
Pass a variable to standard input
Bash Scripts: A here-string supplies the expanded value followed by a newline.
Bash Scripts✓ Tested
Read complete lines into an array
Bash Scripts: Mapfile with -t removes each line terminator but preserves other whitespace.
Bash Scripts✓ Tested
Read from a dedicated file descriptor
Bash Scripts: An explicitly opened descriptor keeps the script’s ordinary standard input available.
Bash Scripts✓ Tested
Read null-delimited filenames into an array
Bash Scripts: A null delimiter preserves spaces and embedded newlines in filenames.
Bash Scripts✓ Tested
Substitute values into a multiline template
Bash Scripts: An unquoted heredoc delimiter enables parameter expansion in the template.
Bash Scripts✓ Tested
Write a literal multiline block
Bash Scripts: Quoting the heredoc delimiter disables parameter and command expansion inside it.
Bash Scripts✓ Tested
Write several messages through one file descriptor
Bash Scripts: Open a destination once and close the descriptor after writing.
Bash Scripts✓ Tested
Capture a command’s success-stream output
PowerShell: Assignment collects output values without requiring text redirection to a file.
PowerShell✓ Tested