Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash command substitution

# Basic syntax:
$(command)

# Example usage:
for file in $(ls)
do
  echo $file
done
--> # all files in your current directory are echoed
Comment

bash variable substitution

${!var}	#Just use to use reference value inside another variable ;)
Comment

bash substitution

## 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
Comment

bash command substitution

# Basic syntax:
$(command)

# Example usage:
for file in $(ls)
do
  echo $file
done
--> # all files in your current directory are echoed
Comment

bash variable substitution

${!var}	#Just use to use reference value inside another variable ;)
Comment

bash substitution

## 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
Comment

PREVIOUS NEXT
Code Example
Shell :: bash get variable value by variable name 
Shell :: unix get time 
Shell :: how to install from a Linux terminal 
Shell :: remove inkscape 
Shell :: zsh deno command not found 
Shell :: view recently installed apps linu 
Shell :: run nock in debug 
Shell :: bash metadata 
Shell :: where are php errors logged 
Shell :: rmd no output 
Shell :: install tidyverse ubuntu 20.04 
Shell :: how to fetch all git branches 
Shell :: re-entering top level after c stack overflow 
Shell :: find and move bash 
Shell :: bash numbering even filename 
Shell :: linux move files one directory up 
Shell :: debian install ab 
Shell :: linux repeat command every second 
Shell :: linux subsystem mount file into windows 
Shell :: get files traked by git based on size 
Shell :: start confluence service ubuntu 
Shell :: kubernetes add or remove label from existing resource 
Shell :: git ignore more then 10MB 
Shell :: Github cli default editor set 
Shell :: scaffold key 
Shell :: awk convert first character to lowercase 
Shell :: git remove submodule 
Shell :: linux find command 
Shell :: push a new local repository to github. 
Shell :: powershell show calendar 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =