Solved

use echo

Posted on 1998-10-01
8
342 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

743 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

13 Experts available now in Live!

Get 1:1 Help Now