Bash Cheat Sheet/Use a here string

Pass a short string to stdin.

Section: Redirection

Use a here string

bash
bash
grep -o '[0-9]\+' <<< 'order-123'
Explanation

Useful for compact one-liners and tests.

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 Redirection
Redirect stdout to file
Overwrite a file with command output.
OpenIn sheetbashsame section
Append stdout to file
Append output to a file.
OpenIn sheetbashsame section
Redirect stderr to file
Write error output to a separate file.
OpenIn sheetbashsame section
Redirect stdout and stderr
Send both stdout and stderr to same file.
OpenIn sheetbashsame section
Discard command output
Silence both stdout and stderr.
OpenIn sheetbashsame section
Use a here document
Feed literal multiline input to a command.
OpenIn sheetbashsame section