remove specific characters from a string Announcing the arrival of Valued Associate #679:...
Protagonist's race is hidden - should I reveal it?
tabularx column has extra padding at right?
If gravity precedes the formation of a solar system, where did the mass come from that caused the gravity?
Is Vivien of the Wilds + Wilderness Reclamation a competitive combo?
A German immigrant ancestor has a "Registration Affidavit of Alien Enemy" on file. What does that mean exactly?
Recursive calls to a function - why is the address of the parameter passed to it lowering with each call?
Short story about an alien named Ushtu(?) coming from a future Earth, when ours was destroyed by a nuclear explosion
A journey... into the MIND
How to keep bees out of canned beverages?
Why is one lightbulb in a string illuminated?
Marquee sign letters
Is Bran literally the world's memory?
Meaning of this sentence, confused by まで
Does Prince Arnaud cause someone holding the Princess to lose?
What is the ongoing value of the Kanban board to the developers as opposed to management
Why do C and C++ allow the expression (int) + 4*5?
Has a Nobel Peace laureate ever been accused of war crimes?
Assertions In A Mock Callout Test
Is there a verb for listening stealthily?
Suing a Police Officer Instead of the Police Department
What is the evidence that custom checks in Northern Ireland are going to result in violence?
Compiling and throwing simple dynamic exceptions at runtime for JVM
Sorting the characters in a utf-16 string in java
Determine the generator of an ideal of ring of integers
remove specific characters from a string
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionBash -Extract characters from stringHow do I delete files with spaces in them in bash script?Tokenize string from $REPLY in bash scriptRemove characters from string with sedRemove characters in a specific column before a specific characterextra space in sed output which impact other scriptRemove certain characters in a text filechange only part of the substring using sedRemove last digit from stringComplex string replace - multiple files, multiple different strings, must include certain text
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I have a scenario where I need to replace spaces with comma and then remove certain extra specific chars from a string.
echo "$d"
>>Mon Apr 22 05:06:00 UTC 2019
jent=$(echo $jt1 | sed 's/[[:space:]]/,/g')
echo "$jent"
>>Mon,Apr,22,05:06:00,UTC,2019 #this does the first job of replacing the space with comma
But again I want to remove the UTC part and the comma before it, how can I achieve it any help?
desired output should be
Mon,Apr,22,05:06:00,2019
scripting shell shell-script sed awk
migrated from serverfault.com 5 hours ago
This question came from our site for system and network administrators.
add a comment |
I have a scenario where I need to replace spaces with comma and then remove certain extra specific chars from a string.
echo "$d"
>>Mon Apr 22 05:06:00 UTC 2019
jent=$(echo $jt1 | sed 's/[[:space:]]/,/g')
echo "$jent"
>>Mon,Apr,22,05:06:00,UTC,2019 #this does the first job of replacing the space with comma
But again I want to remove the UTC part and the comma before it, how can I achieve it any help?
desired output should be
Mon,Apr,22,05:06:00,2019
scripting shell shell-script sed awk
migrated from serverfault.com 5 hours ago
This question came from our site for system and network administrators.
add a comment |
I have a scenario where I need to replace spaces with comma and then remove certain extra specific chars from a string.
echo "$d"
>>Mon Apr 22 05:06:00 UTC 2019
jent=$(echo $jt1 | sed 's/[[:space:]]/,/g')
echo "$jent"
>>Mon,Apr,22,05:06:00,UTC,2019 #this does the first job of replacing the space with comma
But again I want to remove the UTC part and the comma before it, how can I achieve it any help?
desired output should be
Mon,Apr,22,05:06:00,2019
scripting shell shell-script sed awk
I have a scenario where I need to replace spaces with comma and then remove certain extra specific chars from a string.
echo "$d"
>>Mon Apr 22 05:06:00 UTC 2019
jent=$(echo $jt1 | sed 's/[[:space:]]/,/g')
echo "$jent"
>>Mon,Apr,22,05:06:00,UTC,2019 #this does the first job of replacing the space with comma
But again I want to remove the UTC part and the comma before it, how can I achieve it any help?
desired output should be
Mon,Apr,22,05:06:00,2019
scripting shell shell-script sed awk
scripting shell shell-script sed awk
asked 22 hours ago
AlexAlex
31
31
migrated from serverfault.com 5 hours ago
This question came from our site for system and network administrators.
migrated from serverfault.com 5 hours ago
This question came from our site for system and network administrators.
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You can do it with one sed call, e.g.
$ echo "Mon Apr 22 05:06:00 UTC 2019" | sed 's/ (UTC )?/,/g'
Mon,Apr,22,05:06:00,2019
Thanks :-) it worked
– Alex
19 hours ago
add a comment |
You can simply say:
~]$ export jent="$(echo $jent | sed 's/,UTC//g')"
~]$ echo $jent
Mon,Apr,22,05:06:00,2019
add a comment |
You can do it with translate command:
jent=$(echo "$d" | tr -ds UTC " " | tr " " ,)
# the first double quotes contains two spaces
echo "$jent"
Mon,Apr,22,05:06:00,2019
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%2f513914%2fremove-specific-characters-from-a-string%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can do it with one sed call, e.g.
$ echo "Mon Apr 22 05:06:00 UTC 2019" | sed 's/ (UTC )?/,/g'
Mon,Apr,22,05:06:00,2019
Thanks :-) it worked
– Alex
19 hours ago
add a comment |
You can do it with one sed call, e.g.
$ echo "Mon Apr 22 05:06:00 UTC 2019" | sed 's/ (UTC )?/,/g'
Mon,Apr,22,05:06:00,2019
Thanks :-) it worked
– Alex
19 hours ago
add a comment |
You can do it with one sed call, e.g.
$ echo "Mon Apr 22 05:06:00 UTC 2019" | sed 's/ (UTC )?/,/g'
Mon,Apr,22,05:06:00,2019
You can do it with one sed call, e.g.
$ echo "Mon Apr 22 05:06:00 UTC 2019" | sed 's/ (UTC )?/,/g'
Mon,Apr,22,05:06:00,2019
answered 22 hours ago
FreddyFreddy
2,099210
2,099210
Thanks :-) it worked
– Alex
19 hours ago
add a comment |
Thanks :-) it worked
– Alex
19 hours ago
Thanks :-) it worked
– Alex
19 hours ago
Thanks :-) it worked
– Alex
19 hours ago
add a comment |
You can simply say:
~]$ export jent="$(echo $jent | sed 's/,UTC//g')"
~]$ echo $jent
Mon,Apr,22,05:06:00,2019
add a comment |
You can simply say:
~]$ export jent="$(echo $jent | sed 's/,UTC//g')"
~]$ echo $jent
Mon,Apr,22,05:06:00,2019
add a comment |
You can simply say:
~]$ export jent="$(echo $jent | sed 's/,UTC//g')"
~]$ echo $jent
Mon,Apr,22,05:06:00,2019
You can simply say:
~]$ export jent="$(echo $jent | sed 's/,UTC//g')"
~]$ echo $jent
Mon,Apr,22,05:06:00,2019
answered 22 hours ago
Mousa Halaseh
add a comment |
add a comment |
You can do it with translate command:
jent=$(echo "$d" | tr -ds UTC " " | tr " " ,)
# the first double quotes contains two spaces
echo "$jent"
Mon,Apr,22,05:06:00,2019
add a comment |
You can do it with translate command:
jent=$(echo "$d" | tr -ds UTC " " | tr " " ,)
# the first double quotes contains two spaces
echo "$jent"
Mon,Apr,22,05:06:00,2019
add a comment |
You can do it with translate command:
jent=$(echo "$d" | tr -ds UTC " " | tr " " ,)
# the first double quotes contains two spaces
echo "$jent"
Mon,Apr,22,05:06:00,2019
You can do it with translate command:
jent=$(echo "$d" | tr -ds UTC " " | tr " " ,)
# the first double quotes contains two spaces
echo "$jent"
Mon,Apr,22,05:06:00,2019
answered 12 hours ago
Mohamedarif
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%2f513914%2fremove-specific-characters-from-a-string%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