nocom: script that shows files without comments

This commit is contained in:
sndr 2019-04-18 13:42:16 +02:00
parent 91a2ae4a09
commit 215c5f73e2
1 changed files with 32 additions and 0 deletions

32
nocom Normal file
View File

@ -0,0 +1,32 @@
#!/bin/bash
usage (){
echo "Usage: nocom <filename>"
echo ""
echo "nocom simply removes all lines starting with '#'"
echo "and pipes it to less"
echo "nocom -h or nocom --help to view this again"
echo ""
echo "This script is in the public domain."
}
if [ $# -eq 0 ]; then
echo "No filename provided"
usage
exit 1
fi
while getopts ":h:" o; do
case "${o}" in
h)
usage
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
sed -e 's:^\s*#.*$::g' -e '/^$/d' $1 | less