msgbartop
A chronological documentation test project, nothing serious, really!
msgbarbottom

25 May 2007 Strip comments from config files

Posted by

This is at short script to strip/remove comments from config files

#!/bin/bash
# Code to cat a config file removing all comments and blank lines.

grep -vh '^[[:space:]]*#' "$@" | grep -v '^$'

Usage: ./confcat.sh /etc/make.conf

Alternativ is to use sed

cat filename | sed -e 's/#.*//;/^\s*$/d' "$@"

This also strips comments at the end of a line, though it looks a little bit ugly

Tags: , ,

Comments are closed.