How to install a bash function containing variables using a bash script? [duplicate]
This question already has an answer here: How to avoid heredoc expanding variables? [duplicate] 2 answers I am attempting to create a bash script that will allow me to install the same bash function across multiple machines. This particular function creates a copy of a file with a timestamp in a backup directory: filebackup () { cp "${@}" ~/"filebackup/${@}_$(date +%Y-%m-%d_%H:%M:%S).bk"; } Here is my bash script: cat <<EOT >> ~/.bashrc # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # create a file backup in ~/filebackup/ with timestamp filebackup () { cp "${@}