Thursday, May 29, 2008

Shell-Script to add headers to another Shell-Script

I write Shell-Scripts day in day out. For each and every shell-script I need to place following headers at the beginning of it. For e.g. consider following header:

#!/bin/bash
#Author:
#Date:
#Name:
#Usage:
#Purpose:

I have prepared a shell-script to automatically add the above header to the newly created shell-script. Just go through it and let me know if you happen to come across any bug in it:

#!/bin/bash
#Author: Parag Kalra
#Date: 30th May, 2008
#Name: shell-script-header.sh
#Usage: ./shell-script-header.sh
#Purpose: To add headers to shell-scripts

echo "Enter the date: "
read SHDATE

echo "Enter the name of the shell script: "
read SHNAME

echo "Enter the purpose of this shell script: "
read SHPURPOSE


export SHDATE #='$SHDATE'
export SHNAME #='$SHNAME'
export SHPURPOSE #='$SHPURPOSE'

touch $SHNAME

echo "#!/bin/bash" >> $SHNAME
echo "#Author: Parag Kalra" >> $SHNAME
echo "#Date: $SHDATE" >> $SHNAME
echo "#Name: $SHNAME" >> $SHNAME
echo "#Usage: ./$SHNAME" >> $SHNAME
echo "#Purpose: $SHPURPOSE" >> $SHNAME

#END OF SCRIPT

1 comment:

Saurabh said...

Nice!!, Pretty Innovative to start with..