the following sed command should delete the comment/s lines in file – /opt/presto/presto.conf
sed '/^[[:blank:]]*#/d' /opt/presto/presto.conf
in our case we want to delete the comment lines with AND case , means to delete the comment/s lines that also include the string – NOTE
example
more /opt/presto/presto.conf
# task.max-worker-threads=16
#jmx.rmiregistry.port=8091
# jmx.rmiserver.port=8092 /NOTE/
expected output
# task.max-worker-threads=16
#jmx.rmiregistry.port=8091
we try with:
sed '/NOTE/d ; /^[[:blank:]]*#/d' /opt/presto/presto.conf`
but this above sed command delete the lines with NOTE and also the comments lines
>Solution :
This sed should work for you. Here we search for comment marker # at the line start followed by NOTE anywhere in the line:
sed '/^[[:blank:]]*#.*NOTE/d' file
# task.max-worker-threads=16
#jmx.rmiregistry.port=8091
Or this one:
sed '/NOTE/ {/^[[:blank:]]*#/d;}' file