Replacing with sed expressionusing sed for replacing strings with “/”Replacing lines containing a pattern...
English word for "product of tinkering"
GroupBy operation using an entire dataframe to group values
Let M and N be single-digit integers. If the product 2M5 x 13N is divisible by 36, how many ordered pairs (M,N) are possible?
New pedal fell off maybe 50 miles after installation. Should I replace the entire crank, just the arm, or repair the thread?
Who enforces MPAA rating adherence?
Why are trash cans referred to as "zafacón" in Puerto Rico?
Overlapping String-Blocks
Writing an augmented sixth chord on the flattened supertonic
Print lines between start & end pattern, but if end pattern does not exist, don't print
Are polynomials with the same roots identical?
Live action TV show where High school Kids go into the virtual world and have to clear levels
sed + add word before string only if not exists
Artificer Creativity
Second (easy access) account in case my bank screws up
Why am I getting a strange double quote (“) in Open Office instead of the ordinary one (")?
Is it possible to have 2 different but equal size real number sets that have the same mean and standard deviation?
Getting UPS Power from One Room to Another
How to ensure color fidelity of the same file on two computers?
How to handle (one's own) self-harm scars (on the arm), in a work environment?
How to communicate to my GM that not being allowed to use stealth isn't fun for me?
Extreme flexible working hours: how to get to know people and activities?
Why we don’t make use of the t-distribution for constructing a confidence interval for a proportion?
Generate basis elements of the Steenrod algebra
A map of non-pathological topology?
Replacing with sed expression
using sed for replacing strings with “/”Replacing lines containing a pattern with sedSED command not replacing (working regex)Replacing by tab character in Sed in Osxsed - simple regular expression replacement not replacingsed regular expression behaving differently than in vim and perl?Replacing variable containing with sedsed function to replace any config file entryWhy does sed output -e expression #1, char 55: Invalid preceding regular expressionLinux sed command replace two lines having spaces and special characters using regular expression
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'm trying to get a value such as
"909,999"
With this (the example is replacing it with nothing):
sed 's/["][0-9]+[,][0-9]+["]//g'
But it's not working.
sed regular-expression
add a comment |
I'm trying to get a value such as
"909,999"
With this (the example is replacing it with nothing):
sed 's/["][0-9]+[,][0-9]+["]//g'
But it's not working.
sed regular-expression
6
What is the text that you are feeding intosed? Does it work if you run withsed -E(your expression looks like an extended regular expression, unless the pluses are supposed to be literal). Why do you use["]instead of just"? The double quote is not special in a regular expression. Likewise for the comma. Also, you are replacing the matched thing with nothing.
– Kusalananda♦
3 hours ago
add a comment |
I'm trying to get a value such as
"909,999"
With this (the example is replacing it with nothing):
sed 's/["][0-9]+[,][0-9]+["]//g'
But it's not working.
sed regular-expression
I'm trying to get a value such as
"909,999"
With this (the example is replacing it with nothing):
sed 's/["][0-9]+[,][0-9]+["]//g'
But it's not working.
sed regular-expression
sed regular-expression
edited 55 mins ago
Rui F Ribeiro
42.8k1688149
42.8k1688149
asked 3 hours ago
Gabriel A. ZorrillaGabriel A. Zorrilla
249512
249512
6
What is the text that you are feeding intosed? Does it work if you run withsed -E(your expression looks like an extended regular expression, unless the pluses are supposed to be literal). Why do you use["]instead of just"? The double quote is not special in a regular expression. Likewise for the comma. Also, you are replacing the matched thing with nothing.
– Kusalananda♦
3 hours ago
add a comment |
6
What is the text that you are feeding intosed? Does it work if you run withsed -E(your expression looks like an extended regular expression, unless the pluses are supposed to be literal). Why do you use["]instead of just"? The double quote is not special in a regular expression. Likewise for the comma. Also, you are replacing the matched thing with nothing.
– Kusalananda♦
3 hours ago
6
6
What is the text that you are feeding into
sed? Does it work if you run with sed -E (your expression looks like an extended regular expression, unless the pluses are supposed to be literal). Why do you use ["] instead of just "? The double quote is not special in a regular expression. Likewise for the comma. Also, you are replacing the matched thing with nothing.– Kusalananda♦
3 hours ago
What is the text that you are feeding into
sed? Does it work if you run with sed -E (your expression looks like an extended regular expression, unless the pluses are supposed to be literal). Why do you use ["] instead of just "? The double quote is not special in a regular expression. Likewise for the comma. Also, you are replacing the matched thing with nothing.– Kusalananda♦
3 hours ago
add a comment |
1 Answer
1
active
oldest
votes
If you want to replace the pattern, you can use sed -E or escape the + characters as suggested by @Kusalananda:
$ printf '"123.456"n"909,999"n"100"n' | sed -E 's/"[0-9]+,[0-9]+"//g'
"123.456"
"100"
or
$ printf '"123.456"n"909,999"n"100"n' | sed 's/"[0-9]+,[0-9]+"//g'
"123.456"
"100"
Note that the g is not needed in this example as there is only one substitution per line.
If you want to delete the matching line(s), you could use d to delete the pattern space:
$ printf '"123.456"n"909,999"n"100"n' | sed '/"[0-9]+,[0-9]+"/d'
"123.456"
"100"
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%2f523415%2freplacing-with-sed-expression%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
If you want to replace the pattern, you can use sed -E or escape the + characters as suggested by @Kusalananda:
$ printf '"123.456"n"909,999"n"100"n' | sed -E 's/"[0-9]+,[0-9]+"//g'
"123.456"
"100"
or
$ printf '"123.456"n"909,999"n"100"n' | sed 's/"[0-9]+,[0-9]+"//g'
"123.456"
"100"
Note that the g is not needed in this example as there is only one substitution per line.
If you want to delete the matching line(s), you could use d to delete the pattern space:
$ printf '"123.456"n"909,999"n"100"n' | sed '/"[0-9]+,[0-9]+"/d'
"123.456"
"100"
add a comment |
If you want to replace the pattern, you can use sed -E or escape the + characters as suggested by @Kusalananda:
$ printf '"123.456"n"909,999"n"100"n' | sed -E 's/"[0-9]+,[0-9]+"//g'
"123.456"
"100"
or
$ printf '"123.456"n"909,999"n"100"n' | sed 's/"[0-9]+,[0-9]+"//g'
"123.456"
"100"
Note that the g is not needed in this example as there is only one substitution per line.
If you want to delete the matching line(s), you could use d to delete the pattern space:
$ printf '"123.456"n"909,999"n"100"n' | sed '/"[0-9]+,[0-9]+"/d'
"123.456"
"100"
add a comment |
If you want to replace the pattern, you can use sed -E or escape the + characters as suggested by @Kusalananda:
$ printf '"123.456"n"909,999"n"100"n' | sed -E 's/"[0-9]+,[0-9]+"//g'
"123.456"
"100"
or
$ printf '"123.456"n"909,999"n"100"n' | sed 's/"[0-9]+,[0-9]+"//g'
"123.456"
"100"
Note that the g is not needed in this example as there is only one substitution per line.
If you want to delete the matching line(s), you could use d to delete the pattern space:
$ printf '"123.456"n"909,999"n"100"n' | sed '/"[0-9]+,[0-9]+"/d'
"123.456"
"100"
If you want to replace the pattern, you can use sed -E or escape the + characters as suggested by @Kusalananda:
$ printf '"123.456"n"909,999"n"100"n' | sed -E 's/"[0-9]+,[0-9]+"//g'
"123.456"
"100"
or
$ printf '"123.456"n"909,999"n"100"n' | sed 's/"[0-9]+,[0-9]+"//g'
"123.456"
"100"
Note that the g is not needed in this example as there is only one substitution per line.
If you want to delete the matching line(s), you could use d to delete the pattern space:
$ printf '"123.456"n"909,999"n"100"n' | sed '/"[0-9]+,[0-9]+"/d'
"123.456"
"100"
answered 2 hours ago
FreddyFreddy
4,1831420
4,1831420
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%2f523415%2freplacing-with-sed-expression%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
6
What is the text that you are feeding into
sed? Does it work if you run withsed -E(your expression looks like an extended regular expression, unless the pluses are supposed to be literal). Why do you use["]instead of just"? The double quote is not special in a regular expression. Likewise for the comma. Also, you are replacing the matched thing with nothing.– Kusalananda♦
3 hours ago