Need shell script to split line into variables
Posted on 2006-07-21
I am needing a shell script that will help automate sending reports via email to our users. I have everything ready except for one part.
All of the reports that we print has the email address and report name on line 2 of the report. Like this:
firstname.lastname@example.org IC Trial Balance Report
The email address can be different for each report and the report name different as well. There will be spaces to the left of the email address then some amount of spaces between the eamil address and the report name. It is centered on the line. The report is temporarily stored in a file named /var/tmp/report$$.rpt
What I need, is some code to put in a shell script that will look at line 2 of the report, find the email address and split it into one variable and the report name into another. That way I can send the email to the email address variable and use the report name as the subject.
Maybe awk or sed?