: ########################################################################## # Title : cfcat - print contents of configuration files # Author : Heiner Steven # Date : 1993-11-27 # Requires : - # Category : System Administration # SCCS-Id. : @(#) cfcat 1.2 04/02/18 ########################################################################## # Description # - Prints the given files to standard output. Comments and empty # lines are removed, and with "\" continued lines are concatenated # - Comments start with a "#" character, and extend to the end of # the line. Use a leading "\" for a literal "#" character. # See also # cfget ########################################################################## PN=`basename "$0"` # Program name VER='1.2' [ $# -ge 1 -a "$1" = "-h" ] && { echo "$PN - print contents of configuration files, $VER" echo "usage: [file ...]" echo echo "Comments and empty lines are removed." exit 1 } # Print files without empty lines and comments # Description: # o Label "loop" concatenates with "\" continued lines # o processing of quoted '#' characters # o comments are removed # - lines consisting entirely of comments # - lines with trailing comments # o empty lines are removed cat "$@" | sed -n -e ' :loop /\\$/{ h; n; H; x s/\\\n// b loop } /\\#/{ s/\\#/#/g b skip } /^[ ]*#/d /[ ][ ]*#/{ s/^\(.*\)#.*$/\1/ } :skip s/[ ]*$// /^$/d p '