I am writing a basic script that will allow me to call it like so in the terminal: newscript myscript "This is what my script is about"
So this script is taking 2 arguments, first is the name of the new script, second is its description.
And the purpose of this script is to generate some kind of template for any new scripts with commented standard infos at the top of the file like so:
#!/bin/bash
#: Title : $title
#: Date : `date +%m-%d-%Y`
#: Author : $user
#: Version : 1.0
#: Description : $description
So this is what i've got so far but it gives me the syntax error: unexpected end of file when i try to run it:
#!/bin/bash
#### EDITABLES ####
user="user" #
dest="~/bin" #
## END EDITABLES ##
title="$1"
desc="$2"
date=`date +%m-%d-%Y`
## Checks if a file with the same name already exists and returns the exit status (0=true, non-0=false)
fileExists() { [ -f "${1}/${2}" ] || $? }
## If file does not exist, create and populate it, otherwise exit script
if [ ! fileExists ${dest} ${title} ]; then
printf "%b-13 %b\n" "#!/bin/bash" "" "#: Title" ":${title}" "#: Date" ":${date}" "#: Author" ": ${user}" "#: Version" ": 1.0" "#: Description" ": ${desc}" >> ${dest}/${title}
chmod +x ${dest}/${title}
vi ${dest}/${title}
else
echo "The name chosen for your new script is already used. Please choose another name."
exit
fi
unset fileExists
If you have any suggestions on how to fix this, please let me know.