Created
March 21, 2020 01:33
-
-
Save davidlares/dfc65ef52bac7b6b72493f64c2a90137 to your computer and use it in GitHub Desktop.
Performing Shell expansions operations in simple isolated examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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