Emit data to stdout and capture it with command substitution.
Section: Functions
Return data via stdout
bash
bash
slugify() { tr '[:upper:] ' '[:lower:]-' <<< "$1"; }
slug=$(slugify 'Hello World')Explanation
This is the most common shell pattern for function 'return values'.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Functions