I have a file named bitcoin.conf:
#Bind to given address and always listen on it (comment out when not using as a wallet):
#bind=127.0.0.1
daemon=1
#debug=i2p
debug=tor
#Pre-generate this many public/private key pairs, so wallet backups will be valid for
# both prior transactions and several dozen future transactions
keypool=2
#i2pacceptincoming=1
#i2psam=127.0.0.1:8060
#Make outgoing connections only to .onion addresses. Incoming connections are not affected by this option:
onlynet=i2p
onlynet=onion
#running Bitcoin Core behind a Tor proxy i.e. SOCKS5 proxy:
proxy=127.0.0.1:9050
Having studied the answers to this worthy question, I've tried to implement the solutions in a script that is meant to comment out with # a couple of lines:
#!/usr/bin/bash
#Semicolons do not seem to work below.
#This gives me no error but it does not do anything
#sed -Ee 's/^(debug=tor)/#\1/;s/^(onlynet=onion)/#\1/;s/^(proxy=127)/#\1/' bitcoin.conf
#This works fine
sed -Ee s/^(debug=tor)/#\1/ -e s/^(onlynet=onion)/#\1/ -e s/^(proxy=127)/#\1/ bitcoin.conf
#When grouping, and therefore extended regexp, is not applied semicolons seem to work fine
sed -e 's/^debug=tor/#debug=tor/;s/^onlynet=onion/#onlynet=onion/;s/^proxy=127/#proxy=127/' bitcoin.conf
##This gives me no error but it doesn't do anything
#sed -Ee 's/^(debug=tor)/#\1/
s/^(onlynet=onion)/#\1/
s/^(proxy=127)/#\1/' bitcoin.conf
#sed -i -E -e 's/^(debug=tor)/#\1/' -e 's/^(onlynet=onion)/#\1/' -e 's/^(proxy=127)/#\1/'
#-e 's/^(addnode)/#\1/' -e 's/^(seednode)/#\1/' bitcoin.conf #does not comment out anything
Why don't semicolons and newlines work with -E when giving multiple expressions to GNU sed?
P.S. Because of distinct workings of sed with -E I don't consider this question duplicate to the one referenced above.
\(...\)must be changed to(...)with-E.-Eonly changes the type of the regular expressions used bysed. Also note thatsed 's/\(...\)/#\1/(orsed -E 's/(...)/#\1/') can be writtensed 's/.../#&/'– Stéphane Chazelas Jul 30 '22 at 09:04sed -E 's/^(debug=tor)/#\1/;s/^(onlynet=onion)/#\1/;s/^(proxy=127)/#\1/' bitcoin.confworks fine. Would you decode...in your sed commands? – John Smith Jul 30 '22 at 09:39