blob: 2e3a35685cac3ba9b0524996ac81406ef23dd729 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
|
#!/bin/sh
# Strip all comments '#' from a file, including on individual lines and in
# lines, not taking escaping due to, e.g. strings into account.
# Use as: cat filename | strip-comments,
# or as strip-comments filename
[ $# -ge 1 -a -f "$1" ] && in="$1" || in="-"
sed '/^[[:blank:]]*#/d;s/#.*//' "$in"
|