Chris Adams Asked: 2009-07-08 04:49:34 +0800 CST2009-07-08 04:49:34 +0800 CST 2009-07-08 04:49:34 +0800 CST Is there a bash equivalent to "some content #{foo}" with ruby? 772 I'm used to being able to pass variables inside strings in ruby, like so "message in double quotes #{expression_or_variable_to_run}" What's the equivalent in bash, for really quick scripting? bash ruby 2 Answers Voted Best Answer Dan Carley 2009-07-08T05:01:25+08:002009-07-08T05:01:25+08:00 Is this what you're after? #!/bin/bash # Source hostname from command. echo "Hostname is $(hostname)" # Set hostname as string. HOSTNAME="somestring" echo "Hostname is ${HOSTNAME}" Karolis T. 2009-07-08T04:54:20+08:002009-07-08T04:54:20+08:00 Maybe this will help you understand some basics: #!/bin/bash VARIABLE="is" echo "the server $VARIABLE `hostname`" Variables are defined without $, referenced with $. Shell commands can be executed within `` quotes.
Is this what you're after?
Maybe this will help you understand some basics:
Variables are defined without $, referenced with $. Shell commands can be executed within `` quotes.