How to embed the output of a command into a bash script.

Embedding the output of a command into a bash shell script is quite easy.

Here is an example.

echo "Hello $(whoami), the date is $(date -u). Have a nice day"

This is the output this will give you.

┌─[jason@neo]─[~]
└──╼ $echo "Hello $(whoami), the date is $(date -u). Have a nice day."
Hello jason, the date is Saturday 11 February  00:58:10 UTC 2017. Have a nice day.

This way, one-liners may be constructed to output information from a Linux command in one long echo command. This could be very useful.

No comments have been made. Use this form to start the conversation :)

Leave a Reply