Skip to content

Instantly share code, notes, and snippets.

@timjstewart
Created December 18, 2013 21:16
Show Gist options
  • Save timjstewart/8029985 to your computer and use it in GitHub Desktop.
Save timjstewart/8029985 to your computer and use it in GitHub Desktop.
Create a new shell script using an older shell script
#! /bin/bash
if [ "$#" != "1" ]
then
echo "usage: newscript NAME" 1>&2
exit 1
fi
script_name=$1
if [ -f "${script_name}" ]
then
echo "error: ${script_name} already exists." 1>&2
exit 2
fi
cat <<EOF > ${script_name}
#! /bin/bash
# ${script_name} - description
EOF
chmod u+x ${script_name}
if [ ! -z ${EDITOR} ]
then
${EDITOR} ${script_name}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment