# Basic syntax:
$(command)
# Example usage:
for file in $(ls)
do
echo $file
done
--> # all files in your current directory are echoed
${!var} #Just use to use reference value inside another variable ;)
## Bash Substitution - Search/Replace
${var#Pattern}
# Remove the shortest part of $Pattern that matches the front end of $var.
${var##Pattern}
# Remove the longest part of $Pattern that matches the front end of $var.
${var%Pattern}
# Remove the shortest part of $Pattern that matches the back end of $var
${var%%Pattern}
# Remove the longest part of $Pattern that matches the back end of $var
${var/Pattern/Replacement}
# Replace First match of Pattern
# If Replacement is omitted, the first match is replaced by nothing
${var//Pattern/Replacement}
# Global replacement. Replace All matches of Pattern
# if Replacement omitted, all occurrences of Pattern are replaced by nothing
# Basic syntax:
$(command)
# Example usage:
for file in $(ls)
do
echo $file
done
--> # all files in your current directory are echoed
${!var} #Just use to use reference value inside another variable ;)
## Bash Substitution - Search/Replace
${var#Pattern}
# Remove the shortest part of $Pattern that matches the front end of $var.
${var##Pattern}
# Remove the longest part of $Pattern that matches the front end of $var.
${var%Pattern}
# Remove the shortest part of $Pattern that matches the back end of $var
${var%%Pattern}
# Remove the longest part of $Pattern that matches the back end of $var
${var/Pattern/Replacement}
# Replace First match of Pattern
# If Replacement is omitted, the first match is replaced by nothing
${var//Pattern/Replacement}
# Global replacement. Replace All matches of Pattern
# if Replacement omitted, all occurrences of Pattern are replaced by nothing