Skip to content

Commit 1c65d6d

Browse files
authored
[bash/en]: Multiple instance substitution in variables (#5465)
1 parent 281e887 commit 1c65d6d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

bash.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ echo "${variable}" # => Some string
7777
# String substitution in variables:
7878
echo "${variable/Some/A}" # => A string
7979
# This will substitute the first occurrence of "Some" with "A".
80+
# Prepend a / before the search string to substitute every instance of it.
81+
variable="Some string. Some character"
82+
echo "${variable//Some/A}" # => A string. A character
83+
# This will substitute every occurrence of "Some" with "A".
8084

8185
# Substring from a variable:
8286
length=7

0 commit comments

Comments
 (0)