Z
Z
Zenko2019-09-03 16:41:18
bash
Zenko, 2019-09-03 16:41:18

What do //\"/ at the end of a bash variable mean?

The script receives a parameter of this format:
"${1//\"/}"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2019-09-03
@Zenko

It's called bash parameter substitution
https://www.tldp.org/LDP/abs/html/parameter-substi...
Your example is described as
${var//Pattern/Replacement}
Global replacement. All matches of Pattern, within var replaced with Replacement.
Usage example - strips double quotes from input
bash-3.2$ ./test1.sh 'aaa""bbb'
aaabbb
bash-3.2$ cat test1.sh
#!/bin/bash
testvar=${1//\"/}
echo $testvar

V
Valentine, 2019-09-03
@vvpoloskin

Replacing the substring
${string/substring/replacement} The
details are well described here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question