Skip to content

Instantly share code, notes, and snippets.

@davidlares
Last active March 21, 2020 03:25
Show Gist options
  • Save davidlares/c0f8172ee54e0d22ffa2f523156e2d45 to your computer and use it in GitHub Desktop.
Save davidlares/c0f8172ee54e0d22ffa2f523156e2d45 to your computer and use it in GitHub Desktop.
A simple command substitution example with bash scripting
#!/bin/bash
# doing some simple substitution using ``
TODAYSDATE=`date`
USERFILES=`find . -user david`
echo "Today's Date: $TODAYSDATE"
echo "All files by USER: $USERFILES"
# other way of using substitution, using aliases
# expanding aliases -> normally this are represented on the bash_profile
shopt -s expand_aliases # expanding aliases to the subshells (override)
# setting the aliases
alias TODAY="date" # alias uses double quotes
alias UFILES="find . -user david" # find files and directories of the user "david"
# assiging alias to names
A=`TODAY`
B=`UFILES`
# printing
echo "With alias, Today is: $A"
echo "With alias, All files are in: $B"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment