print a multi-lines variable?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting print a multi-lines variable?
# 1  
Old 03-18-2009
Question print a multi-lines variable?

hi im trying a make simple html page with the content of some files
i have:
title=`cat "file1"`
heading=`cat "file2"`
para=`cat "file3"`
block=`cat "/file4"`
cat > ./page.html <<-EOF
<html>
<head>
<title>$title</title>
</head>
<body>
<h1>$heading</h1>
<p>$para</p>
<blockquote>$block</blockquote>
</body>
</html>
EOF

lets say file2 contains:
222
222

and file3 contains:
333

333

my script will only give me a html page with variables printed in single lines like:
222 222
333 333

the result i want should be:
222
222
333

333

sorry about the bad english and poor explaination, please help me Smilie
thank you
# 2  
Old 03-18-2009
Try this:
Code:
heading=`sed -e 's/$/<br \/>/' file2 > /tmp/file2.$$ ; cat /tmp/file2.$$ ; \rm -f /tmp/file2.$$`
para=`sed -e 's/$/<br \/>/' file3 > /tmp/file3.$$ ; cat /tmp/file3.$$ ; \rm -f /tmp/file3.$$`

Not very clean but ... Smilie
# 3  
Old 03-18-2009
Thank you very much Goldorakk
that worked
though i only used:
heading=`sed 's/$/<br \/>/' file2`
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Print number of lines for files in directory, also print number of unique lines

I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with: wc -l *|sort 15263 Image.txt 16401 reference.txt 40459 richtexteditor.txt How can I also print the number of unique lines in each file? 15263 1401 Image.txt 16401... (15 Replies)
Discussion started by: spacegoose
15 Replies

2. Shell Programming and Scripting

Print lines present in first that match second variable. And ones that does not exist in second.

I have multi line input(var1) and reference(var2) variables. How to capture lines not present in var2 but present in var1? How to capture lines present var2 but not in var1? # configuration from server var1=""" Custom JAX-RS Custom Shared Web 2.0 """ # required configuration... (6 Replies)
Discussion started by: kchinnam
6 Replies

3. Shell Programming and Scripting

Quick and easy way to comment out multi lined print statements

Is there a quick and easy way to comment out multi lined print statements? something like this? printf("3408 strings_line_tokens %s \n", strings_line_tokens); (6 Replies)
Discussion started by: cokedude
6 Replies

4. Shell Programming and Scripting

Print between multi line pattern

Hi, I have a file with text like this .SET WIDTH 10000 .SET MAXERROR 1 insert into new_db SELECT * FROM some_db ; +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+- .SET WIDTH 10000... (3 Replies)
Discussion started by: sol_nov
3 Replies

5. Shell Programming and Scripting

[Perl] Split lines into array - variable line items - variable no of lines.

Hi, I have the following lines that I would like to see in an array for easy comparisons and printing: Example 1: field1,field2,field3,field4,field5 value1,value2,value3,value4,value5Example 2: field1,field3,field4,field2,field5,field6,field7... (7 Replies)
Discussion started by: ejdv
7 Replies

6. UNIX for Dummies Questions & Answers

checking multi lines with if

hi all, i have a file containing list of dials as below with some extra field as below ####### 20101665110 ####### MSISDN=20101665110 TC=15000.0 TU=2011-03-02T19:39:03Z MSISDN=20101665110 TC=15000.0 TU=2011-03-02T19:39:04Z MSISDN=20101665110 TC=15000.0 TU=2011-03-02T19:39:04Z #######... (1 Reply)
Discussion started by: Maghraby
1 Replies

7. UNIX for Dummies Questions & Answers

sed print certain lines matching variable

I have a very large results file, and a list of filters grep -wf filterlist.txt datafile.txt > outfile.txt The above line works but is very slow and I'm wondering how to make it faster. The items in my filterlist are only relevant to the first column. I don't care if any item in the... (1 Reply)
Discussion started by: sayb
1 Replies

8. Shell Programming and Scripting

print lines AFTER lines cointaining a regexp (or print every first and fourth line)

Hi all, This should be very easy but I can't figure it out... I have a file that looks like this: @SRR057408.1 FW8Y5CK02R652T length=34 AGCAGTGGTATCAACGCAGAGTAAGCAGTGGTAT +SRR057408.1 FW8Y5CK02R652T length=34 FIIHFF6666?=:88@@@BBD:::?@ABBAAA>8 @SRR057408.2 FW8Y5CK02TBMHV length=52... (1 Reply)
Discussion started by: kmkocot
1 Replies

9. Shell Programming and Scripting

Reading multi lines variable using shell script

Hi, I am using #!/bin/sh shell. I have a variable which contains multi line data. I want to read that variable line by line. Can someone post the code to read the multi line variable line by line? Any help is much appreciated. (2 Replies)
Discussion started by: gupt_ash
2 Replies

10. UNIX for Dummies Questions & Answers

How to print multi page to one for pdf in unix??

I need help on printing PS and PDF file. I find it will waste a lot of paper if I print every pages. So I want to print multipage into one. But I forgot how to do it in unix. Anyone help me!!! :D ;) :p (2 Replies)
Discussion started by: sunartio
2 Replies
Login or Register to Ask a Question