Emailing Script Contents With Bash
When experimenting on our development servers in the office here we often find ourselves wanting to quickly backup the contents of whatever bash script we are testing before making further changes to the script.
You can use the cat and mail commands to email the contents of the script to yourself like so:
cat fileyouwant.sh | mail -s “Email subject is here, script” youremail@domain.com
We used cat with pipe ( | ) to read the contents of the file and pass it to the mail command. We set the subject of the email using the -s parameter, and specified the email address at the end of the mail command.
