Source
-
to comment a line (and preserve indentation)
sed -Ei '/<pattern>/s/^(\s*)/\1# /g' -
to uncomment a line (and preserve indentation)
sed -Ei '/<pattern>/s/^(\s*)#\s?/\1/g'
Source
to comment a line (and preserve indentation)
sed -Ei '/<pattern>/s/^(\s*)/\1# /g'to uncomment a line (and preserve indentation)
sed -Ei '/<pattern>/s/^(\s*)#\s?/\1/g'