Another way to supply the terminal output of one BASH command to another
Published on 26th April 2023 Estimated Reading Time: 1 minuteMy usual way for sending the output of one command to another is to be place one command after another, separated by the pipe (|
) operator, adjusting the second command as needed. However, I recently found that this approach does not work well for docker pull
commands until I uncovered another option.
The solution is to enclose the input command in $( )
within the output command. Within the parentheses, any kind of command can be declared and includes anything with piping as part of it. As long as text is being printed to the terminal, it can be fed to the second command and used as required. Thus, you can have something like the following:
docker pull $([command outputting name of image to download])
This approach has helped with other kinds of automation of docker image and container use and deployment because it is so general. There may be other uses found for the approach yet.