echo a block of lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting echo a block of lines
# 1  
Old 10-04-2006
Bug echo a block of lines

echo "line 1"
echo "line 2"
echo "..."
echo "..."
echo "line n-1"
echo "line n"

How can I echo n number of lines with one 'echo' command?
# 2  
Old 10-04-2006
either
Code:
echo "
line1
line2
...
lineN"

or

Code:
cat <<EOF
line1
line2
...
lineN
EOF

# 3  
Old 10-04-2006
Code:
echo -e "line1\nline2\nline3"

if -e option is not there
use

Code:
printf "line1\nline2\nline3"

# 4  
Old 10-05-2006
MySQL

Thanks to all.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash Script: Echo continuation across many lines

I am writing a bash script that automatically generates a macro program. I want to have an echo on multiple lines and getting an error /home/chaos/instru-correct.sh: line 309: command line is: command not found I am using echo "# The general synopsis of the $mfl" \ ... (2 Replies)
Discussion started by: kristinu
2 Replies

2. Shell Programming and Scripting

Echo printing a line in 2 lines; expected to print in one line

Dear All, fileName: therm.txt nc3h7o2h 7/27/98 thermc 3h 8o 2 0g 300.000 5000.000 1390.000 41 1.47017550e+01 1.71731699e-02-5.91205329e-06 9.21842570e-10-5.36438880e-14 2 -2.99988556e+04-4.93387892e+01 2.34710908e+00 4.34517484e-02-2.65357553e-05 3 ... (7 Replies)
Discussion started by: linuxUser_
7 Replies

3. Shell Programming and Scripting

Printing a block of lines from a file, if that block does not contain two patterns using sed

I want to process a file block by block using sed, and if that block does not contain two patterns, then that complete block has to be printed. See below for the example data. ................................server 1............................... running process 1 running... (8 Replies)
Discussion started by: Kesavan
8 Replies

4. UNIX for Advanced & Expert Users

Move a block of lines to file if string found in the block.

I have a "main" file which has blocks of data for each user defined by tags BEGIN and END. BEGIN ID_NUM:24879 USER:abc123 HOW:47M CMD1:xyz1 CMD2:arp2 STATE:active PROCESS:id60 END BEGIN ID_NUM:24880 USER:def123 HOW:4M CMD1:xyz1 CMD2:xyz2 STATE:running PROCESS:id64 END (7 Replies)
Discussion started by: grep_me
7 Replies

5. Shell Programming and Scripting

extracting block of lines from a file

consider the input file which i am dealing with looks like this.. #cat 11.sql create table abc ( . . . ) engine=Innodb ; . . etc . . . create table UsM ( blah blah blah ) engine=Innodb ; (5 Replies)
Discussion started by: vivek d r
5 Replies

6. Shell Programming and Scripting

Echo print in different lines within email sent by Cron job

Hi all, I think this could have a simple solution, just I canīt get it so far. I have the script below that includes several echo commands in order to show that every part of the script have been executed. A cron job executes this script and when is completed the output is sent by email. ... (4 Replies)
Discussion started by: cgkmal
4 Replies

7. UNIX for Dummies Questions & Answers

echo multiple lines

I have a code: echo "First Line ^M Second Line" | mail -s "Lines" abc@gmail.com Basically, I want to send an email with text in this format: First Line Second Line But there is something wrong with my 'echo'. The ^M is not interpreted as carriage return. Please help. (6 Replies)
Discussion started by: laiko
6 Replies

8. Shell Programming and Scripting

Grep between block of lines in a file

Hi Friends, I have a file which has many of the statements like below ******** MAKING > noun1 < cg_all statements statements statements ********* MAKING > noun2 < cg_all statements statements statements ********* MAKING > noun3 < all statements statements statements I would... (3 Replies)
Discussion started by: ganga.dharan
3 Replies

9. Shell Programming and Scripting

echo on several lines

Hi there, I managed to write a script that display its progress like this: ~# cat myscript echo -en ' Completed\015' for (( i=0; i<=100; i++ )) do echo -ne $i'%\015' # perform some actions sleep .01 done echo ~# myscript 100% Completed ~#I can't show it on this post, but... (2 Replies)
Discussion started by: chebarbudo
2 Replies

10. UNIX for Dummies Questions & Answers

combine 2 lines (command & echo)

does anyone know how to combine 2 lines? this is what im playing around with. (filename: online, user name: prml0001, real name: primal) #!/bin/sh who | grep $1 > /dev/null if then grep $1 /etc/passwd | cut -f 5, -d : echo is logged on exit 0 else grep $1... (13 Replies)
Discussion started by: primal
13 Replies
Login or Register to Ask a Question