Since EVERY shell script needs these 2 attributes, it might be a good idea to have a script that can do those 2 things for you.
What this script does is adds the shebang (#!/bin/bash) into a file and makes the file executable (700).
This script will help you code other scripts.
Code: Select all
#!/bin/bash
# Purpose: Inserts #!/bin/bash into a file and makes it executable
# Usage: scriptname /path/to/file.sh
# Author: JJ/Habitual
# Date: Tue Jul 19, 2011
# Version: 1311133977
# Disclaimer: Use it, abuse it, just don't lose it.
MINPARAMS=1
if [ -n "$1" ]
then
echo "#!/bin/bash" > $1
chmod 700 "$1"
echo File $1 is now an executable and ready to be edited.
fi
if [ $# -lt "$MINPARAMS" ]
then
echo Usage: `pwd`/`basename $0` /path/to/script.sh
fi
exit 0
Code: Select all
chmod 700 /path/to/saved/script.sh
Enjoy! Now let's code something!!!