Bash replace special character 'Reading character by character with bash readHow to do more than one...
Is there any practical application for performing a double Fourier transform? ...or an inverse Fourier transform on a time-domain input?
What magic extends life or grants immortality?
Non-visual Computers - thoughts?
What is the best option for High availability on a data warehouse?
Fried gnocchi with spinach, bacon, cream sauce in a single pan
Can you feel passing through the sound barrier in an F-16?
Compelling story with the world as a villain
Using `With[...]` with a list specification as a variable
Defense against attacks using dictionaries
Is using a hyperlink to close a modal a poor design decision?
See details of old sessions
If all stars rotate, why was there a theory developed, that requires non-rotating stars?
LeetCode: Pascal's Triangle C#
What is the hex versus octal timeline?
for loop not working in bash
If the first law of thermodynamics ensures conservation of energy, why does it allow systems to lose energy?
Did a flight controller ever answer Flight with a no-go?
Is "The life is beautiful" incorrect or just very non-idiomatic?
Cross-referencing enumerate item
Why different interest rates for checking and savings?
Is the term "small" applied differently between piston engine planes and jet engine planes?
Did the British navy fail to take into account the ballistics correction due to Coriolis force during WW1 Falkland Islands battle?
Does travel insurance for short flight delays exist?
C++20 constexpr std::copy optimizations for run-time
Bash replace special character '
Reading character by character with bash readHow to do more than one substring replace at once in bash?Replace very long string in files recursivelyReplace specified character between two strings?Replace underscores with spaces for all files in directoryReplace substringHow to replace last occurence of a character?Search and replace substring with an other in all the files of a folder and all its subfoldersHow to replace one char to get many strings in Shell?Bash prompt special character not expanded in PS1
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
All the questions and answers i already read are not my solution. So, all i want to do is to replace the special char '
in bash.
This works:
A="abc"
B="${A//[b]/x}"
But this does not work:
A="a'b"
B="${A//[']/'}"
Also, i have tried:
B="${A//[']/\'}"
B="${A//[']/\'}"
B="${A//[']/'''}"
B="${A//[']/'\''}"
But B
keeps to be a'b
.
linux bash debian string replace
add a comment |
All the questions and answers i already read are not my solution. So, all i want to do is to replace the special char '
in bash.
This works:
A="abc"
B="${A//[b]/x}"
But this does not work:
A="a'b"
B="${A//[']/'}"
Also, i have tried:
B="${A//[']/\'}"
B="${A//[']/\'}"
B="${A//[']/'''}"
B="${A//[']/'\''}"
But B
keeps to be a'b
.
linux bash debian string replace
add a comment |
All the questions and answers i already read are not my solution. So, all i want to do is to replace the special char '
in bash.
This works:
A="abc"
B="${A//[b]/x}"
But this does not work:
A="a'b"
B="${A//[']/'}"
Also, i have tried:
B="${A//[']/\'}"
B="${A//[']/\'}"
B="${A//[']/'''}"
B="${A//[']/'\''}"
But B
keeps to be a'b
.
linux bash debian string replace
All the questions and answers i already read are not my solution. So, all i want to do is to replace the special char '
in bash.
This works:
A="abc"
B="${A//[b]/x}"
But this does not work:
A="a'b"
B="${A//[']/'}"
Also, i have tried:
B="${A//[']/\'}"
B="${A//[']/\'}"
B="${A//[']/'''}"
B="${A//[']/'\''}"
But B
keeps to be a'b
.
linux bash debian string replace
linux bash debian string replace
asked 2 days ago
MSauerMSauer
152 bronze badges
152 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
This way works:
A="a'b"
B="${A//'/\'}"
Two notes:
- The
[]
are unnecessary when only one character is inside of them - You need to escape
and
'
inside of the substitution.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f536546%2fbash-replace-special-character%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This way works:
A="a'b"
B="${A//'/\'}"
Two notes:
- The
[]
are unnecessary when only one character is inside of them - You need to escape
and
'
inside of the substitution.
add a comment |
This way works:
A="a'b"
B="${A//'/\'}"
Two notes:
- The
[]
are unnecessary when only one character is inside of them - You need to escape
and
'
inside of the substitution.
add a comment |
This way works:
A="a'b"
B="${A//'/\'}"
Two notes:
- The
[]
are unnecessary when only one character is inside of them - You need to escape
and
'
inside of the substitution.
This way works:
A="a'b"
B="${A//'/\'}"
Two notes:
- The
[]
are unnecessary when only one character is inside of them - You need to escape
and
'
inside of the substitution.
answered 2 days ago
Joseph SibleJoseph Sible
1,4843 silver badges13 bronze badges
1,4843 silver badges13 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f536546%2fbash-replace-special-character%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown