The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help needed please. jerryboy78 UNIX for Dummies Questions & Answers 3 03-16-2008 02:06 PM
Little help needed. Netghost AIX 5 08-10-2006 02:29 PM
Help needed dsravan Shell Programming and Scripting 2 07-20-2006 09:37 AM
awk help needed. cskumar Shell Programming and Scripting 0 07-20-2006 07:24 AM
Sed help needed stevefox Shell Programming and Scripting 5 12-05-2005 01:44 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-14-2008
Alecs Alecs is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 7
Help needed in sed

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
  #2 (permalink)  
Old 06-14-2008
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Try one of these:
Code:
file_content=`cat item_list`
sed -e 's/@ITEMS@/'"`echo \"$file_content\"`"'/g' items_report_template > items_report
or:
Code:
sed -e "s/@ITEMS@/`cat item_list`/g" items_report_template > items_report
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0