So I needed to take in a pasted stdin that was multiple lines. Using just read or any of the flags it provides don’t give a nice clean way to do this. However, using cat and sed, you can provide a few nice ways to allow a user to end the input stream and submit their entry:

Ctrl+d:

#!/bin/bash
echo "Pipe in certificate, or paste and it ctrl-d when done"  
keyvariable=$(cat)  

Blank Line:

#!/bin/bash</p><p>
echo "Paste certificate and end with a blank line:"  
keyvariable=$(sed '/^$/q')  

Thanks, stackoverflow

Blog Logo

Mario Loria


Published

Image

./scriptthe.net

Because 127.0.0.1 gets old after a while.

Back to Overview