Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Remove comment that spans a whole line (like this one)
# and comments at the end of a line like the following
: echo "Hello" # comment at the end of a line
sed -e 's/#.*$//g' -e '/^[ \t]*$/d' file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment