Several shell scripts in a wrapper pretending to be automation. User assumes all risk. http://functions.sh/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

28 lines
682 B

#!/bin/bash
# @author:'@jakimfett'
# @license;'cc-by-sa'
# @todo allow targeting?
fileName="${1}"
if [ ! "${fileName}" == '' ]; then
BASHPLACE=`which bash`
bashLine=`head -1 ${fileName}`
echo ${bashLine}
if [[ "${bashLine}" == *"# !/"* ]]; then
tail -n +2 "${fileName}" > "${fileName}.bak" && mv "${fileName}.bak" "${fileName}" && sed -i.bak "1s;^;# !${BASHPLACE}\n;" f.sh
echo
echo "Replaced:"
echo "'${bashLine}' with '# !${BASHPLACE}'"
echo "in '${fileName}'"
echo
else
sed -i.bak "1s;^;# !${BASHPLACE}\n;" f.sh
echo
echo "Added '${BASHPLACE}'"
echo "to '${fileName}'"
fi
exit 0
else
echo "specify a filename, please"
fi