Posted: . At: 12:07 PM. This was 7 years ago. Post ID: 10189
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


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.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.