SOURCEFILE="/etc/squid/squid.conf" TARGETFILE="/etc/squid/squid.new.conf" # Remove Hash lead lines from file, then spaced hash lead, then blank lines grep -v '^ *#' $SOURCEFILE | grep -v '^[ ]#' | grep -v '^$' > $TARGETFILE