how to display multiline text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to display multiline text
# 1  
Old 02-05-2009
how to display multiline text

I am writing script that can run on solaris 10, Linux Fedora and windows taht has cybwin installed.

I want to display a variable containing muli-line text.

using echo command, the variable display all rows in single line i.e. it loses the format.

Is there any other command that displays the text exactly multil-lined and that can run on all above mentioned platforms.

Moazzam
# 2  
Old 02-05-2009
Question

How do you know it is multi-lined?
Are there embedded <CR> or <LF> characters?

Can you provide a sample?
# 3  
Old 02-05-2009
Quote:
Originally Posted by mmunir
I am writing script that can run on solaris 10, Linux Fedora and windows taht has cybwin installed.

I want to display a variable containing muli-line text.

using echo command, the variable display all rows in single line i.e. it loses the format.

Is there any other command that displays the text exactly multil-lined and that can run on all above mentioned platforms.

Always quote variables when referencing their values:

Code:
echo "$var"

Due to the inconsistencies between different versions of echo, printf is a better choice:

Code:
printf "%s\n" "$var"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need grep regex to extract multiline text between two strings

I have a file conatining the below: --- 10.9.16.116: /tmp/5835113081224811756.jar: hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb /tmp/4603745991442278706.jar: hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb 10.9.14.126: /tmp/conf/extra/httpd-ssl.conf: hash:... (1 Reply)
Discussion started by: mohtashims
1 Replies

2. UNIX for Dummies Questions & Answers

Text display

I am running a Rasberry Pi using the Rasbpian OS. I have a program that develops a log file. If I look at the log file with a terminal session I can CAT it and it contains just what I expect. If I go to the desktop file manager and double click the file opening it with the text editor nothing... (3 Replies)
Discussion started by: barrygordon
3 Replies

3. Shell Programming and Scripting

Remove multiline text between brackets

I have some text in a file like so This is {the first day of} my life. What I would like as output is This is my life. Any text between the curly braces is removed. In the forums I've found statements like sed 's/<*>//g' but the problem is that I think that... (12 Replies)
Discussion started by: climatron
12 Replies

4. Shell Programming and Scripting

Read a multiline text from a console - supporting arrow keys

Hi, I try to read a multiline text from a console and write it to a file using a bash script. I want to end reading from a console if a user types the key twice. I tried this loop: while read LINE; do if 2>/dev/null; then break fi echo -e ${LINE} >> $file done However, it doesn't... (8 Replies)
Discussion started by: wenclu
8 Replies

5. Shell Programming and Scripting

Change/Delete Multiline text

Hi, I want to change/delete all occurences of a multiline text in a file which match the specific pattern: aaa <This text should be changed>bbb ccc ddddddd eee<This text should be changed> fff gggggg hhh<This text should be deleted> iii jjjj kkkkk<This text should be... (1 Reply)
Discussion started by: wenclu
1 Replies

6. Shell Programming and Scripting

How to replace word with multiline text using shell scripting.

Hi all I have data files which contain data as shown below: Line 5: FIDE INST_DESC: DIAM Co Ltd/Japan => MAID Co Ltd/Japan INST_NME: DIAM Co Ltd/Japan => MAID Co Ltd/Japan Line 6: FIDE INST_DESC: DIAM DL/Pimco US Bond Open Born in the USA => MAID DL/Pimco US Bond Open Born in the... (6 Replies)
Discussion started by: Ganesh_more
6 Replies

7. Shell Programming and Scripting

Parsing and filtering multiline text into comma separated line

I have a log file that contains several reports with following format. <Start of delimiter> Report1 header Report1 header continue Report1 header continue Record1 header Record1 header continue Record1 header continue field1 field2 field3 field4 ------... (1 Reply)
Discussion started by: yoda9691
1 Replies

8. Shell Programming and Scripting

perl : replace multiline text between two marker points

Hi there I just wondered if someone could give me some perl advice I have a bunch of text files used for a wiki that have common headings such as ---++ Title blah ---++ Summary blah ---++ Details Here is the multiline block of text I wish to (6 Replies)
Discussion started by: rethink
6 Replies

9. Shell Programming and Scripting

display 5 lines from the particular text

Hi All, please help me to display 5 continious lines from a particular text. my file is as below. file1.txt ------ Good 1 2 3 4 5 luck 1 2 3 I want to diplay 5 lines from the word Good. (4 Replies)
Discussion started by: little_wonder
4 Replies

10. Shell Programming and Scripting

grep command to replace multiline text from httpd.conf file on Fedora

Hi, I am a newbie to shell scripting and to Linux environment as well. In my project I am trying to search for following text from the httpd.conf file <Directory '/somedir/someinnerdir'> AllowOverride All </Directory> and then remove this text and again rewrite the same text. The... (1 Reply)
Discussion started by: bhushan
1 Replies
Login or Register to Ask a Question