Skip to main content
2 of 2
added 13 characters in body
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265

Howto split stdin into multiple multiline strings and put each of them into different bash variables

I'm searching for a possibility to send via pipe several multiline strings to a bash script and grab each of them within this script. Finally, I want to store each multiline string into its own variable.

printf "$some_multiline_string" "$another_multiline_string" | some_script.sh some_params

Inside of bash:

#!/bin/bash
file1=$(</dev/stdin)
file2=$(</dev/stdin)
...

How to split stdin into multiple multiline variables?