[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

echo new line

Posted on 2006-11-10
22
Medium Priority
?
30,499 Views
Last Modified: 2013-11-18
echo 'hello \n there'

doesnt appear as

hello
there

Why ?
0
Comment
Question by:PradeepYadhav
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
  • 2
  • +4
22 Comments
 
LVL 37

Accepted Solution

by:
Harisha M G earned 1000 total points
ID: 17913000
echo hello & echo there
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17913066
Because \n isn't an option in batch programming... as had been said combine two echo commands in one line with an ampersand or just put it on two lines...

echo hello
echo there

echo.    gives a blank line btw

Is there a bigger issue you are dealing with here or does that cover it?

Steve
0
 

Author Comment

by:PradeepYadhav
ID: 17913188
I am trying to write in to a file with new lines
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

Author Comment

by:PradeepYadhav
ID: 17913198
echo 'hello blank line there' > file
0
 

Author Comment

by:PradeepYadhav
ID: 17913202
echo 'hello newline there' > file
0
 

Author Comment

by:PradeepYadhav
ID: 17913204
ouput

hello
there
0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 1000 total points
ID: 17913227
OK You just need to do
echo hello > file.txt
echo there >> file.txt

>> appends
> creates new

hth

Steve
0
 

Author Comment

by:PradeepYadhav
ID: 17913235
right thats what I am doing. I wanted to execute one echo command to fill a file with line breaks.. Thats not possible. Thank U.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17913255
You can't do that.  You can easily do a loop though.

del file.txt 2>NUL
for /l %a in (1,1,50) do echo. >> file.txt

which will delete the file then add 50 new lines.

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17917953
Pradeep, are you still there?  You were very quick to respond before but then went quiet?

Steve
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 17920176
ECHO command always generates one full line.
In other words, a line break is put at the end of text displayed by ECHO command, always.

ECHO. - gives an emty line (a line break)

It is possible to do much more if an ANSI.SYS driver is installed. ANSI graphics enables ESC commands capable of:
- cursor moving in every direction,
- cursor positioning in desired coordinates
- curson position storing and going back to the stored position
- removing lines from the screen
- changing character colors and attributes
- clearing the screen
and more.

But, the ANSI commands are screen related, and will not work if redirecter to a file, as far as I know.
0
 
LVL 24

Expert Comment

by:SunBow
ID: 18000623
ansi.sys was cool
0
 
LVL 24

Expert Comment

by:SunBow
ID: 18000628
Q> echo 'hello \n there'
> doesnt appear as desired, why?

The \n is from c language, not from microsoft batch commands
0
 
LVL 4

Expert Comment

by:Caudax
ID: 18123336
ANSI.SYS is cool but the affiliated (F3 = DELTREE /Y C:\WINDOWS\) ANSIBOMB wasn't as appreciated.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18123524
Doh, now you've restarted the 21 days to cleanup clock again...
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18255557
OK, or Accept me... since we found out he wanted to write newlines to a file
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18255587
Thought about that, but in truth - the opening question was how to write two outputs with a single command...
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18255666
Not the end of the world either way, eh!

Perhaps I should have added a smiley on the end of that last comment

Steve
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18255680
It wouldn't have helped.
Cash is always good though...lol
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18255707
Hmm, pounds for points, sounds good.... if only it worked the other way around we'd be rich ;-)
Off to bed now!

Steve
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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 how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

650 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