catgrep
#!/bin/bash
################################################################################
# 24 jun 2016 - john meister copyright 2016 http://johnmeister.com/linux
# cat's file, then greps out blank lines and comments, offers option to save
################################################################################
USAGE="catgrep filename # removed commented and blank lines, option to save"
echo ' --------------------------------------------------------------------'
echo " DISPLAYING: --> $1 <-- without commented or blank lines"
echo ' --------------------------------------------------------------------'
cat $1 | grep -E -v '(^#|^$)'
echo "save info? Y,y"
echo '-----------------------------------------------------------------'
read answer ; if [ $answer = "y" ]
then
echo "$1" | tee $1-content-`date +%Y%b%d-%H%M`.txt
cat $1 | grep -E -v '(^#|^$)' | tee -a $1-content-`date +%Y%b%d-%H%M`.txt
echo '-----------------------------------------------------------------'
echo " info written to: $1-content-`date +%Y%b%d-%H%M`.txt "
echo '-----------------------------------------------------------------'
else
echo ' ### ------------------------------------'
echo ' ### info not written.'
echo ' ### ------------------------------------'
fi
|