I have files in below name format

1-filename.txt 2-filename.txt 3-filename.txt

1-demofile.txt 2-demofile.txt 3-demofile.txt

Now when I run shell script with below command


Awk -F '#_' '{print FILENAME, NF}' ?-filename.txt | uniq -c

Awk -F '#_' '{print FILENAMEME, NF}' ?-demofile.txt | uniq -c

Then i get output as below

10 1-filename.txt 5

10 2-filename.txt 8

10 3-filename.txt 7

10 1-demofile.txt 20

10 2-demofile.txt 20

10 3-demofile.txt 20

Output which I am getting is correct I want all these output to be sent on mail.

How to do that in the script itself.


Have a look at metasend in the metamail package.

You need a locally running mail server (which can be something like masqmail that just forwards it to the "real" server).


mail -S subject address < file is the simplest way to send file in unix. You can use file as attachment also as shown below

echo "$BODY" | mail -s "$SUBJECT" -a file $EMAIL_ADDRESS

where $BODY has contents of email $SUBJECT has subject file is the file to be attached $EMAIL_ADDRESS is email address

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.