Solved

use echo

Posted on 1998-10-01
8
346 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
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:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now