Learn › Linux Foundations
Heredocs
Feed multi-line text directly into commands without creating files first. Use heredocs, tab-stripped heredocs, herestrings, and process substitution to build flexible data pipelines.
Labs in this module
- The << Heredoc - Feed a multi-line block of text straight into any command with the << heredoc: pick a delimiter word, close the block exactly, quote the del
- The <<< Herestring - Feed one string to any stdin-reading command with the herestring <<<: no temporary file, no heredoc delimiter. Drilled against cat, grep, wc
- The <<- Tab-Stripped Heredoc - One dash turns << into <<-, the heredoc that strips leading tabs from its body and closing delimiter so you can indent blocks inside scripts
- Process Substitution - A command dressed as a file: process substitution <(...) lets diff compare two live commands with no temp files, a one-line ; echo $? reads