473,386 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Newline in the shell

Joe
I have just written my first php script that runs as a shell script. I
run it using CLI that comes with my Win32 distro of php (4.3.4).
Everythings works nicely accept for one thing: \n doesnt work in my
echo statements. So in practices:

echo "hello\nworld"; becomes helloworld and not
hello
world

I have a suspicion that it has something to do with windows using a
different kind of new line syntax than Unix, but I cant remember/find
an example of how it should be done.

In case this is the problem, what is the proper syntax, and if not what
is the problem then?

Joe
Jul 17 '05 #1
4 2580

"Joe" <am***********@hotmail.com> wrote in message
news:40*********************@dread12.news.tele.dk. ..
I have just written my first php script that runs as a shell script. I
run it using CLI that comes with my Win32 distro of php (4.3.4).
Everythings works nicely accept for one thing: \n doesnt work in my
echo statements. So in practices:

echo "hello\nworld"; becomes helloworld and not
hello
world

I have a suspicion that it has something to do with windows using a
different kind of new line syntax than Unix, but I cant remember/find
an example of how it should be done.

In case this is the problem, what is the proper syntax, and if not what
is the problem then?

Joe


\r\n maybe, or the other way around =P Cant Remember which.
Jul 17 '05 #2
*** Joe wrote/escribió (Tue, 01 Jun 2004 13:49:49 +0200):
echo "hello\nworld";
Works fine for me:

#!/usr/bin/php

<?
echo "Hello\nWorld"
?>
I have a suspicion that it has something to do with windows using a
different kind of new line syntax than Unix, but I can’t remember/find
an example of how it should be done.


MacOS - \r
Unix - \n
Windows - \r\n
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #3

"Joe" <am***********@hotmail.com> wrote in message
news:40*********************@dread12.news.tele.dk. ..
I have just written my first php script that runs as a shell script. I
run it using CLI that comes with my Win32 distro of php (4.3.4).
Everythings works nicely accept for one thing: \n doesnt work in my
echo statements. So in practices:

echo "hello\nworld"; becomes helloworld and not
hello
world

I have a suspicion that it has something to do with windows using a
different kind of new line syntax than Unix, but I cant remember/find
an example of how it should be done.

In case this is the problem, what is the proper syntax, and if not what
is the problem then?

Joe


Joe,

Works fine on my system with PHP 4.3.6 win32.
Not too sure what is causing this problem for you. I've never seen it
before. Are you redirecting the output somewhere?
Nathan

Jul 17 '05 #4
Joe
> Works fine on my system with PHP 4.3.6 win32.
Not too sure what is causing this problem for you. I've never seen it
before. Are you redirecting the output somewhere?
Nathan


My mistake!

echo "\n"; //works but
echo '\n'; //dosn't

Stupid mistake, sorry for the inconvenient
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paul Watson | last post by:
I thought that using a comma at the end of a print statement would suppress printing of a newline. Am I misunderstanding this feature? How can I use print and not have a newline appended at the...
5
by: nek | last post by:
Hi, Is it possible to echo a newline in window shell script? eg. @echo this is the 1st line @echo ??? @echo this is the 3rd line The result expected:
9
by: Alan Mackenzie | last post by:
To all those who use (X)Emacs's CC Mode to edit C, C++, Java, Objective-C, Pike, AWK or IDL: To help direct the development of CC Mode, it would be useful to find out how people use the...
29
by: runningdog | last post by:
Hi, I would like to be able to embed a newline in a text string. Is there any convienent notation to do this TIA Steve
7
by: Alex Nordhus | last post by:
I am looking for a way to strip the blank line and the empty newline at the end of the text file. I can get the blank lines removed from the file but it always leaves the end line (which is blank)...
4
by: Peter Kirk | last post by:
Hi I would like to ask a little bit about the value Environment.Newline: what is it and what is the point of it? Ok, I can see in the docs that it represents "newline" for the current platform -...
5
by: Adam Right | last post by:
Hi, Is there a way to construct the mail body including newline characters by using .net framework mailing functions when sending an email? I cannot insert newline character into the body of the...
11
by: rossum | last post by:
I want to declare a const multi-line string inside a method, and I am having some problems using Environment.NewLine. I started out with: class foo { public void PrintStuff() { const...
1
by: linq936 | last post by:
Hi, I read in many places that the string to be outputted by printf() must be ending with newline, for example, it should be printf("Hello World.\n"); instead of printf("Hello World.");
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.