Split echo's output on two lines

Clash Royale CLAN TAG#URR8PPP up vote
-2
down vote
favorite
It is written in the manual that /n will split the output of echo command to the next line. I tried:
echo -e 'hello /n world'
hello /n world
Expecting 'world' on the next line. I failed.
command-line echo
add a comment |Â
up vote
-2
down vote
favorite
It is written in the manual that /n will split the output of echo command to the next line. I tried:
echo -e 'hello /n world'
hello /n world
Expecting 'world' on the next line. I failed.
command-line echo
4
In which manual is it written that /n will do that?
â muru
Mar 15 at 12:02
add a comment |Â
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
It is written in the manual that /n will split the output of echo command to the next line. I tried:
echo -e 'hello /n world'
hello /n world
Expecting 'world' on the next line. I failed.
command-line echo
It is written in the manual that /n will split the output of echo command to the next line. I tried:
echo -e 'hello /n world'
hello /n world
Expecting 'world' on the next line. I failed.
command-line echo
command-line echo
edited Mar 15 at 13:19
Melebius
3,81341636
3,81341636
asked Mar 15 at 11:41
Josef Klimuk
542112
542112
4
In which manual is it written that /n will do that?
â muru
Mar 15 at 12:02
add a comment |Â
4
In which manual is it written that /n will do that?
â muru
Mar 15 at 12:02
4
4
In which manual is it written that /n will do that?
â muru
Mar 15 at 12:02
In which manual is it written that /n will do that?
â muru
Mar 15 at 12:02
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
10
down vote
accepted
Your mistake is to use /n instead of n.
So just try echo -e 'hello nworld' and you will get what you expect.
Notice that I have removed the space between n and world. Else the second line will start with a space.
add a comment |Â
up vote
3
down vote
n is new line not /n
You should try this:
echo -e 'hello n world'
add a comment |Â
up vote
2
down vote
From man echo:
-e enable interpretation of backslash escapes
-E disable interpretation of backslash escapes (default)
If -e is in effect, the following sequences are recognized:
\ backslash
a alert (BEL)
b backspace
c produce no further output
e escape
f form feed
n new line
r carriage return
t horizontal tab
v vertical tab
NNN byte with octal value NNN (1 to 3 digits)
xHH byte with hexadecimal value HH (1 to 2 digits)
NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.
Please note the NOTE :) For example in sh there is no option -e for echo:
$ sh -c "echo -e 'hello n world'"
-e hello
world
You can see -e is output as regular text but the backslash escape is interpreted as it is expected.
add a comment |Â
up vote
1
down vote
A straight-forward alternative is to use manifest line feeds in the quoted string,
echo "hello
world"
If you want to see the alignment, press enter after the first quotation character
echo "
hello beautiful
wonderful world"
and remove that line feed to avoid a blank first line of the output.
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
10
down vote
accepted
Your mistake is to use /n instead of n.
So just try echo -e 'hello nworld' and you will get what you expect.
Notice that I have removed the space between n and world. Else the second line will start with a space.
add a comment |Â
up vote
10
down vote
accepted
Your mistake is to use /n instead of n.
So just try echo -e 'hello nworld' and you will get what you expect.
Notice that I have removed the space between n and world. Else the second line will start with a space.
add a comment |Â
up vote
10
down vote
accepted
up vote
10
down vote
accepted
Your mistake is to use /n instead of n.
So just try echo -e 'hello nworld' and you will get what you expect.
Notice that I have removed the space between n and world. Else the second line will start with a space.
Your mistake is to use /n instead of n.
So just try echo -e 'hello nworld' and you will get what you expect.
Notice that I have removed the space between n and world. Else the second line will start with a space.
edited Mar 15 at 13:21
Melebius
3,81341636
3,81341636
answered Mar 15 at 11:46
rebrec
1816
1816
add a comment |Â
add a comment |Â
up vote
3
down vote
n is new line not /n
You should try this:
echo -e 'hello n world'
add a comment |Â
up vote
3
down vote
n is new line not /n
You should try this:
echo -e 'hello n world'
add a comment |Â
up vote
3
down vote
up vote
3
down vote
n is new line not /n
You should try this:
echo -e 'hello n world'
n is new line not /n
You should try this:
echo -e 'hello n world'
answered Mar 15 at 11:45
Goran Vrbaà ¡ki
31616
31616
add a comment |Â
add a comment |Â
up vote
2
down vote
From man echo:
-e enable interpretation of backslash escapes
-E disable interpretation of backslash escapes (default)
If -e is in effect, the following sequences are recognized:
\ backslash
a alert (BEL)
b backspace
c produce no further output
e escape
f form feed
n new line
r carriage return
t horizontal tab
v vertical tab
NNN byte with octal value NNN (1 to 3 digits)
xHH byte with hexadecimal value HH (1 to 2 digits)
NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.
Please note the NOTE :) For example in sh there is no option -e for echo:
$ sh -c "echo -e 'hello n world'"
-e hello
world
You can see -e is output as regular text but the backslash escape is interpreted as it is expected.
add a comment |Â
up vote
2
down vote
From man echo:
-e enable interpretation of backslash escapes
-E disable interpretation of backslash escapes (default)
If -e is in effect, the following sequences are recognized:
\ backslash
a alert (BEL)
b backspace
c produce no further output
e escape
f form feed
n new line
r carriage return
t horizontal tab
v vertical tab
NNN byte with octal value NNN (1 to 3 digits)
xHH byte with hexadecimal value HH (1 to 2 digits)
NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.
Please note the NOTE :) For example in sh there is no option -e for echo:
$ sh -c "echo -e 'hello n world'"
-e hello
world
You can see -e is output as regular text but the backslash escape is interpreted as it is expected.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
From man echo:
-e enable interpretation of backslash escapes
-E disable interpretation of backslash escapes (default)
If -e is in effect, the following sequences are recognized:
\ backslash
a alert (BEL)
b backspace
c produce no further output
e escape
f form feed
n new line
r carriage return
t horizontal tab
v vertical tab
NNN byte with octal value NNN (1 to 3 digits)
xHH byte with hexadecimal value HH (1 to 2 digits)
NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.
Please note the NOTE :) For example in sh there is no option -e for echo:
$ sh -c "echo -e 'hello n world'"
-e hello
world
You can see -e is output as regular text but the backslash escape is interpreted as it is expected.
From man echo:
-e enable interpretation of backslash escapes
-E disable interpretation of backslash escapes (default)
If -e is in effect, the following sequences are recognized:
\ backslash
a alert (BEL)
b backspace
c produce no further output
e escape
f form feed
n new line
r carriage return
t horizontal tab
v vertical tab
NNN byte with octal value NNN (1 to 3 digits)
xHH byte with hexadecimal value HH (1 to 2 digits)
NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.
Please note the NOTE :) For example in sh there is no option -e for echo:
$ sh -c "echo -e 'hello n world'"
-e hello
world
You can see -e is output as regular text but the backslash escape is interpreted as it is expected.
answered Mar 15 at 11:53
pa4080
12.3k52256
12.3k52256
add a comment |Â
add a comment |Â
up vote
1
down vote
A straight-forward alternative is to use manifest line feeds in the quoted string,
echo "hello
world"
If you want to see the alignment, press enter after the first quotation character
echo "
hello beautiful
wonderful world"
and remove that line feed to avoid a blank first line of the output.
add a comment |Â
up vote
1
down vote
A straight-forward alternative is to use manifest line feeds in the quoted string,
echo "hello
world"
If you want to see the alignment, press enter after the first quotation character
echo "
hello beautiful
wonderful world"
and remove that line feed to avoid a blank first line of the output.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
A straight-forward alternative is to use manifest line feeds in the quoted string,
echo "hello
world"
If you want to see the alignment, press enter after the first quotation character
echo "
hello beautiful
wonderful world"
and remove that line feed to avoid a blank first line of the output.
A straight-forward alternative is to use manifest line feeds in the quoted string,
echo "hello
world"
If you want to see the alignment, press enter after the first quotation character
echo "
hello beautiful
wonderful world"
and remove that line feed to avoid a blank first line of the output.
answered Mar 15 at 12:59
sudodus
20.3k32668
20.3k32668
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1015151%2fsplit-echos-output-on-two-lines%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
4
In which manual is it written that /n will do that?
â muru
Mar 15 at 12:02