Solved

use echo

Posted on 1998-10-01
8
351 Views
Last Modified: 2013-12-06
This is probably a very stupid question but how do you use echo to print multiple carriage returns, without retyping
echo
echo
echo
over and over again.
0
Comment
Question by:platiumstar
8 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2007160
echo "\n\n\n"

0
 
LVL 2

Expert Comment

by:kellyjj
ID: 2007161
ozo should get the points for this one.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007162
ozo's answer might work in some cases.
But unfortunately most shells have their own implementation of
echo (shell built-in), and this is, --to make make things more
crazy-- different on several platforms.

/bin/echo "\n\n\n"

If you have HP-UX and you're using csh, try to find mcsh on your
system.
should work anywhere.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:platiumstar
ID: 2007163
that's what I thought, echo "\n\n\n".
but it doesn't work, I tried to get into all the shell's we have but none of them will work.I tried tcsh, csh, sh(bourne shell),
but none of them will work. is there any reason why? I also checked the environmental variables but nothing sets echo.

0
 
LVL 84

Expert Comment

by:ozo
ID: 2007164
What does echo "\n\n\n" do for you?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007165
as I said: this is one of the deep secrets (for all those people
who didn't know them;-))

Search for a external program echo:
  find / -name echo -print

Then try following:

   echo "\n\n"
   \echo "\n\n"
   /path/reported/by/find-command/above/echo "\n\n"

you may try it in different shells (sh first).
0
 

Expert Comment

by:tsmoore
ID: 2007166
If you are trying to print lots of text, you could always use a 'here document' instead of echo, thus:

cat <<END_OF_TEXT
line 1
line 2
line 3
.etc
END_OF_TEXT

This way you are only using one command, and it is also easier to see how it would be spaced on the screen.
0
 
LVL 4

Accepted Solution

by:
davidmwilliams earned 50 total points
ID: 2007167
 Use the -n option to echo - though, note the built-in ksh echo does not have this option, and on certain systems sh may not either, but csh does.  In any case, you will undoubtedly have a binary version of echo that you can use, which supports -n, that is not a shell built-in.
  -n allows you to make up a multi-line echo statement, like this -

echo -n "


   Hi there


"

and then you will get that entire message, including all the blank lines, echoed out.  This works fine in a shell script, or directly on the command line.

Regards,
 David Williams
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question