Skip to content

Instantly share code, notes, and snippets.

@davidlares
Created March 21, 2020 01:33
Show Gist options
  • Save davidlares/dfc65ef52bac7b6b72493f64c2a90137 to your computer and use it in GitHub Desktop.
Save davidlares/dfc65ef52bac7b6b72493f64c2a90137 to your computer and use it in GitHub Desktop.
Performing Shell expansions operations in simple isolated examples
#!/bin/bash
# shell expansion -> ability to use shortcuts to manage ouputs
echo sh{ot,ort,oot} # print out a list
echo st{il, al}l
# getting the HOME directory
echo ~
export NETPATH=PATH:~
env | grep NEWPATH
export NEWPATH=$PATH:~/bin
env | grep NEWPATH
# pwd equivalent
echo ~+
# old pwd
echo ~-
# instead of
env | grep "HO*"
# you should
echo "${!HO*}"
# set a variable and print at the same time
echo "${VARNAME:=valuesomething}"
echo $VARNAME
# for expressions
echo "$[ 2 * 2 ]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment