Last active
March 21, 2020 03:25
-
-
Save davidlares/c0f8172ee54e0d22ffa2f523156e2d45 to your computer and use it in GitHub Desktop.
A simple command substitution example with bash scripting
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 | |
# 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