2025-12-16 10:20:31 -07:00
# <
2025-03-14 21:59:59 -06:00
> Redirect data to `stdin`.
> More information: <https://gnu.org/software/bash/manual/bash.html#Redirecting-Input>.
- Redirect a file to `stdin` (achieves the same effect as `cat file.txt |` ):
`{{command}} < {{path/to/file.txt}}`
- Create a here document and pass that into `stdin` (requires a multiline command):
2025-06-28 19:25:29 -06:00
`{{command}} << {{EOF}} <Enter> {{multiline_text}} <Enter> {{EOF}}`
2025-03-14 21:59:59 -06:00
- Create a here string and pass that into `stdin` (achieves the same effect as `echo string |` ):
`{{command}} <<< {{string}}`
- Process data from a file and write the output to another file:
`{{command}} < {{path/to/file.txt}} > {{path/to/file2.txt}}`
- Write a here document into a file:
`cat << {{EOF}} > {{path/to/file.txt}} <Enter> {{multiline_data}} <Enter> {{EOF}}`
- Disregard leading tabs (good for scripts with indentation but does not work for spaces):
`cat <<- {{EOF}} > {{path/to/file.txt}} <Enter> {{multiline_data}} <Enter> {{EOF}}`
2025-06-28 19:25:29 -06:00
2026-02-18 06:55:01 -07:00
- Pass command output to a program as a file descriptor (Note: unlike the rest of these, this replaces the argument in-place with a file path like `/dev/fd/63` ):
2025-06-28 19:25:29 -06:00
`diff <({{command1}}) <({{command2}})`
2025-12-16 10:20:31 -07:00
- Open a persistent file descriptor:
`exec {{3}}<{{path/to/file}}`