#!/usr/bin/env bash H=$(head -1 bashrc.head) T=$(head -1 bashrc.tail) BASHRC_FILENAME="${HOME}/.bashrc" HEAD_EXISTS="0" TAIL_EXISTS="0" grep --fixed-strings "${H}" "${BASHRC_FILENAME}" if [ "$?" -eq "0" ] then HEAD_EXISTS="1" fi grep --fixed-strings "${T}" "${BASHRC_FILENAME}" if [ "$?" -eq "0" ] then TAIL_EXISTS="1" fi if [ "${HEAD_EXISTS}" -eq "0" ] then cat bashrc.head "${BASHRC_FILENAME}" > "${BASHRC_FILENAME}.in" cat "${BASHRC_FILENAME}.in" > "${BASHRC_FILENAME}" rm -vf "${BASHRC_FILENAME}.in" fi if [ "${TAIL_EXISTS}" -eq "0" ] then cat "${BASHRC_FILENAME}" bashrc.tail > "${BASHRC_FILENAME}.in" cat "${BASHRC_FILENAME}.in" > "${BASHRC_FILENAME}" rm -vf "${BASHRC_FILENAME}.in" fi