Let’s say you have some program that is generating output to STDOUT and you want to write a script to read that output from STDIN and use it as a variable in your script.
To do so:
#!/bin/bash
SOME_VAR=$(cat)
echo "SOME_VAR = $SOME_VAR"
Principal Software Engineer/Architect, motorcyclist, drummer, and artist
Let’s say you have some program that is generating output to STDOUT and you want to write a script to read that output from STDIN and use it as a variable in your script.
To do so:
#!/bin/bash
SOME_VAR=$(cat)
echo "SOME_VAR = $SOME_VAR"