Skip to content

Instantly share code, notes, and snippets.

@libcrack
Created February 7, 2016 05:20
Show Gist options
  • Select an option

  • Save libcrack/b5b80a7d83e085ec85bf to your computer and use it in GitHub Desktop.

Select an option

Save libcrack/b5b80a7d83e085ec85bf to your computer and use it in GitHub Desktop.
### Derefence a shell variable
# ~ $ deref teag
# value of [teag] is: []
# ~ $ deref HOME
# value of [HOME] is: [/home/libcrack]
deref(){
if [ -n "$1" ]; then
localvar=$(eval echo \$$1)
echo "value of [${1}] is: [${localvar}]"
else
echo "Null parameter passed to this function"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment