uncommenting text with sed is not working [duplicate]Why does my regular expression work in X but not in...
Is refusing to concede in the face of an unstoppable Nexus combo punishable?
What magic extends life or grants immortality
What is wrong about this application of Kirchhoffs Current Law?
Why is Boris Johnson visiting only Paris & Berlin if every member of the EU needs to agree on a withdrawal deal?
Why don't we use Cavea-B
Can my boyfriend, who lives in the UK and has a Polish passport, visit me in the USA?
If I have a 16.67% fail rate (N=24) & I do another 24 tests, what is the likelihood that I get 0 fails by chance?
In what ways can a Non-paladin access Paladin spells?
Justifying the use of directed energy weapons
Do ability scores have any effect on casting Wish spell
How to compare two different formulations of a problem?
Was Switzerland really impossible to invade during WW2?
How do I make distance between concentric circles equal?
How is "sein" conjugated in this sub-sentence?
Why don't electrons take the shorter path in coils
How would one country purchase another?
Is there any practical application for performing a double Fourier transform? ...or an inverse Fourier transform on a time-domain input?
Why does my house heat up, even when it's cool outside?
What is the hex versus octal timeline?
Vacuum collapse -- why do strong metals implode but glass doesn't?
Why is my Earth simulation slower than the reality?
In the MCU, why does Mjölnir retain its enchantments after Ragnarok?
How do I find the fastest route from Heathrow to an address in London using all forms of transport?
Were there 486SX revisions without an FPU on the die?
uncommenting text with sed is not working [duplicate]
Why does my regular expression work in X but not in Y?Replace regex capture group content using sedHow can I delete all text between curly brackets in a multiline text file?Nginx - access from a public ip address - ubuntu 14.04Remove the exact same matching lines with sedReplacing matching text after two matching linessed multiple statements within a single command not workinggrab text out of vtt filePagespeed + Nginx installation from source failsReplace spaces with sed and regexp grouping not workingsed - calling a variable from a file with multiline
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
This question already has an answer here:
Why does my regular expression work in X but not in Y?
1 answer
I'm trying to uncomment a 4 line section in an (nginx config) file. Using sed
. I first tried with grep and the regexp seems to be correct:
$ grep ^#.*bny /etc/nginx/sites-enabled/default
# location /bny {
However when I try with sed to delete the #
at the start of the line it fails:
$ sudo sed -i '/^#.*bny/,+3 s/^#+//' /etc/nginx/sites-enabled/default
$ grep ^#.*bny /etc/nginx/sites-enabled/default
# location /bny {
I think I use the same tactics for commenting the section with sed and that works just fine:
sudo sed -i '/bny/,+3 s/^/#/' /etc/nginx/sites-enabled/default
Even double commenting is no problem. What am I doing wrong with the uncommenting?
ubuntu sed
marked as duplicate by G-Man, msp9011, Community♦ yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Why does my regular expression work in X but not in Y?
1 answer
I'm trying to uncomment a 4 line section in an (nginx config) file. Using sed
. I first tried with grep and the regexp seems to be correct:
$ grep ^#.*bny /etc/nginx/sites-enabled/default
# location /bny {
However when I try with sed to delete the #
at the start of the line it fails:
$ sudo sed -i '/^#.*bny/,+3 s/^#+//' /etc/nginx/sites-enabled/default
$ grep ^#.*bny /etc/nginx/sites-enabled/default
# location /bny {
I think I use the same tactics for commenting the section with sed and that works just fine:
sudo sed -i '/bny/,+3 s/^/#/' /etc/nginx/sites-enabled/default
Even double commenting is no problem. What am I doing wrong with the uncommenting?
ubuntu sed
marked as duplicate by G-Man, msp9011, Community♦ yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Related, if not a dupe: Why does my regular expression work in X but not in Y?
– Kusalananda♦
2 days ago
add a comment |
This question already has an answer here:
Why does my regular expression work in X but not in Y?
1 answer
I'm trying to uncomment a 4 line section in an (nginx config) file. Using sed
. I first tried with grep and the regexp seems to be correct:
$ grep ^#.*bny /etc/nginx/sites-enabled/default
# location /bny {
However when I try with sed to delete the #
at the start of the line it fails:
$ sudo sed -i '/^#.*bny/,+3 s/^#+//' /etc/nginx/sites-enabled/default
$ grep ^#.*bny /etc/nginx/sites-enabled/default
# location /bny {
I think I use the same tactics for commenting the section with sed and that works just fine:
sudo sed -i '/bny/,+3 s/^/#/' /etc/nginx/sites-enabled/default
Even double commenting is no problem. What am I doing wrong with the uncommenting?
ubuntu sed
This question already has an answer here:
Why does my regular expression work in X but not in Y?
1 answer
I'm trying to uncomment a 4 line section in an (nginx config) file. Using sed
. I first tried with grep and the regexp seems to be correct:
$ grep ^#.*bny /etc/nginx/sites-enabled/default
# location /bny {
However when I try with sed to delete the #
at the start of the line it fails:
$ sudo sed -i '/^#.*bny/,+3 s/^#+//' /etc/nginx/sites-enabled/default
$ grep ^#.*bny /etc/nginx/sites-enabled/default
# location /bny {
I think I use the same tactics for commenting the section with sed and that works just fine:
sudo sed -i '/bny/,+3 s/^/#/' /etc/nginx/sites-enabled/default
Even double commenting is no problem. What am I doing wrong with the uncommenting?
This question already has an answer here:
Why does my regular expression work in X but not in Y?
1 answer
ubuntu sed
ubuntu sed
asked 2 days ago
dr jerrydr jerry
1891 gold badge3 silver badges8 bronze badges
1891 gold badge3 silver badges8 bronze badges
marked as duplicate by G-Man, msp9011, Community♦ yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by G-Man, msp9011, Community♦ yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by G-Man, msp9011, Community♦ yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Related, if not a dupe: Why does my regular expression work in X but not in Y?
– Kusalananda♦
2 days ago
add a comment |
1
Related, if not a dupe: Why does my regular expression work in X but not in Y?
– Kusalananda♦
2 days ago
1
1
Related, if not a dupe: Why does my regular expression work in X but not in Y?
– Kusalananda♦
2 days ago
Related, if not a dupe: Why does my regular expression work in X but not in Y?
– Kusalananda♦
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
+
is literal in basic regular expression (BRE) syntax, so your substitution pattern fails to match.
You can use s/^##*//
, s/^#{1,}//
or (in GNU sed) s/^#+//
, or switch to extended regular expressions (ERE) using the -E
or -r
command line option.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
+
is literal in basic regular expression (BRE) syntax, so your substitution pattern fails to match.
You can use s/^##*//
, s/^#{1,}//
or (in GNU sed) s/^#+//
, or switch to extended regular expressions (ERE) using the -E
or -r
command line option.
add a comment |
+
is literal in basic regular expression (BRE) syntax, so your substitution pattern fails to match.
You can use s/^##*//
, s/^#{1,}//
or (in GNU sed) s/^#+//
, or switch to extended regular expressions (ERE) using the -E
or -r
command line option.
add a comment |
+
is literal in basic regular expression (BRE) syntax, so your substitution pattern fails to match.
You can use s/^##*//
, s/^#{1,}//
or (in GNU sed) s/^#+//
, or switch to extended regular expressions (ERE) using the -E
or -r
command line option.
+
is literal in basic regular expression (BRE) syntax, so your substitution pattern fails to match.
You can use s/^##*//
, s/^#{1,}//
or (in GNU sed) s/^#+//
, or switch to extended regular expressions (ERE) using the -E
or -r
command line option.
answered 2 days ago
steeldriversteeldriver
42.3k5 gold badges56 silver badges94 bronze badges
42.3k5 gold badges56 silver badges94 bronze badges
add a comment |
add a comment |
1
Related, if not a dupe: Why does my regular expression work in X but not in Y?
– Kusalananda♦
2 days ago