Skip to main content
added 161 characters in body
Source Link
dr_
  • 32.4k
  • 22
  • 102
  • 147

You can use backticks to store the result of a command (in my example, it's uname) on a variable, then echo it onscreen, and eventually use it as argument to mkdir:

FOO=`uname -n`
echo "$FOO"
mkdir "$FOO" 

The excellent Advanced Bash-Scripting Guide has a whole chapter about Command Substitution.

As @KalvinLee commented, the preferred format is now $(...):

FOO=$(uname -n)

You can use backticks to store the result of a command (in my example, it's uname) on a variable, then echo it onscreen, and eventually use it as argument to mkdir:

FOO=`uname -n`
echo "$FOO"
mkdir "$FOO" 

The excellent Advanced Bash-Scripting Guide has a whole chapter about Command Substitution.

You can use backticks to store the result of a command (in my example, it's uname) on a variable, then echo it onscreen, and eventually use it as argument to mkdir:

FOO=`uname -n`
echo "$FOO"
mkdir "$FOO" 

The excellent Advanced Bash-Scripting Guide has a whole chapter about Command Substitution.

As @KalvinLee commented, the preferred format is now $(...):

FOO=$(uname -n)
added 161 characters in body
Source Link
dr_
  • 32.4k
  • 22
  • 102
  • 147

You can use backticks to store the result of a command (in my example, it's uname) on a variable, then echo it onscreen, and eventually use it as argument to mkdir:

FOO=`uname -n`
echo "$FOO"
mkdir "$FOO" 

The excellent Advanced Bash-Scripting Guide has a whole chapter about Command Substitution.

You can use backticks to store the result of a command (in my example, it's uname) on a variable, then echo it onscreen, and eventually use it as argument to mkdir:

FOO=`uname -n`
echo "$FOO"
mkdir "$FOO" 

You can use backticks to store the result of a command (in my example, it's uname) on a variable, then echo it onscreen, and eventually use it as argument to mkdir:

FOO=`uname -n`
echo "$FOO"
mkdir "$FOO" 

The excellent Advanced Bash-Scripting Guide has a whole chapter about Command Substitution.

Always quote your variables, especially when using paths
Source Link
MatthewRock
  • 7.2k
  • 7
  • 35
  • 55

You can use backticks to store the result of a command (in my example, it's uname) on a variable, then echo it onscreen, and eventually use it as argument to mkdir:

FOO=`uname -n`
echo $FOO"$FOO"
mkdir $FOO"$FOO" 

You can use backticks to store the result of a command (in my example, it's uname) on a variable, then echo it onscreen, and eventually use it as argument to mkdir:

FOO=`uname -n`
echo $FOO
mkdir $FOO 

You can use backticks to store the result of a command (in my example, it's uname) on a variable, then echo it onscreen, and eventually use it as argument to mkdir:

FOO=`uname -n`
echo "$FOO"
mkdir "$FOO" 
Source Link
dr_
  • 32.4k
  • 22
  • 102
  • 147
Loading