Skip to content

Instantly share code, notes, and snippets.

@randomessence
Last active August 29, 2015 14:17
Show Gist options
  • Save randomessence/16dd9145785a7c36dec6 to your computer and use it in GitHub Desktop.
Save randomessence/16dd9145785a7c36dec6 to your computer and use it in GitHub Desktop.
variable expansion
# Make the test folder we will work in.
mkdir -p ~/mytest && cd ~/mytest
# Export the test variables.
export testvar1="000 111 222 333 444" && export testvar2="555 666 777 888 999"
# create a folder using command or paramter substitution and testvar1
mkdir $(echo $testvar1) && ls
mkdir ${testvar1} && ls
mkdir $testvar1 && ls
# Result = 5 separate folders
# create a folder using command or paramter substitution and testvar2
mkdir "$(echo $testvar2)" && ls
mkdir "${testvar2}" && ls
mkdir "$testvar2" && ls
# Result = 1 folder with a 5 part name
# reset folder.
rm -rf ~/mytest/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment