I have a requirement in my project to create report from a template file.
A sample template file is added below:
Quote:
items_report_template
These are the items to be added in the stock
@ITEMS@
blah..
blah..
|
The report data is stored in a file. A sample data file is added below:
Quote:
item_list
Item1 50
Item2 80
Item3 10
Item4 100
Item5 150
|
Using the above template and data file I want to create a report like this:
Quote:
These are the items to be added in the stock
Item1 50
Item2 80
Item3 10
Item4 100
Item5 150
blah..
blah..
|
I have tried to create this report by using
sed. This is what I have tried:
Quote:
if [ -f item_list ]; then
file_content=`cat item_list`
sed -e 's/@ITEMS@/'"`echo $file_content`"'/g' items_report_template > items_report
fi
|
The report is getting generated, but the problem I am facing is that the item list in the report is showing in a single line. Is there a way (using
sed or otherwise) I can generate the report as mentioned above, by displaying each items in seperate lines. Any help would be highly appreciated.
Thank You
Alecs