Search code examples
awkgrepmailx

use the content of a file as subject mailx


i need to send a weekly email containing some dynamic information that will be collected in a txt file. what i can't accomplish is adding the content of that file into the subject of my email. my file is named bkp.txt and has one line "weekly backups; total: 10; size: 3gb"

is there any way i can send an email using this format

mailx -s "weekly backups; total: 10; size: 3gb" "email.address@domain.com" < another.txt, keeping in mind the content of bkp txt can modidy every week?

thanks!


Solution

  • Use bash command substitution:

    mailx -s "$(<bkp.txt)" ......