Solved

use echo

Posted on 1998-10-01
8
360 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Question on web subscription for apps 3 118
Linux: disable vim auto-comment 7 155
Image not there 4 63
Element alignment and word wrapping 9 79
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

713 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