how can i return the output of a text [duplicate]
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
0
down vote
favorite
This question already has an answer here:
How can I print multiline output on the same line?
8 answers
This is related to a question i asked in overflow, It remains unanswered so i though I'd try asking it in segments
My objective is to return the special n function, If i were to run
echo -e "My name is nnick rock and i nlive by the sea shore." > file
Then when i cat that file you get something like this
My name is
nick rock and i
live by the sea shore.
What I'm looking to do is reverse the n return function, so when i echo the file with something like this
echo -aoE '([a-zA-Z])1,5' file
output
My
name
is
nick
rock
and
i
live
by
the
sea
shore.
I'll get this instead
My name is nick rock and i live by the sea shore
command-line text-processing
marked as duplicate by Sergiy Kolodyazhnyy
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jun 1 at 0:07
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
This question already has an answer here:
How can I print multiline output on the same line?
8 answers
This is related to a question i asked in overflow, It remains unanswered so i though I'd try asking it in segments
My objective is to return the special n function, If i were to run
echo -e "My name is nnick rock and i nlive by the sea shore." > file
Then when i cat that file you get something like this
My name is
nick rock and i
live by the sea shore.
What I'm looking to do is reverse the n return function, so when i echo the file with something like this
echo -aoE '([a-zA-Z])1,5' file
output
My
name
is
nick
rock
and
i
live
by
the
sea
shore.
I'll get this instead
My name is nick rock and i live by the sea shore
command-line text-processing
marked as duplicate by Sergiy Kolodyazhnyy
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jun 1 at 0:07
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
How can I print multiline output on the same line?
8 answers
This is related to a question i asked in overflow, It remains unanswered so i though I'd try asking it in segments
My objective is to return the special n function, If i were to run
echo -e "My name is nnick rock and i nlive by the sea shore." > file
Then when i cat that file you get something like this
My name is
nick rock and i
live by the sea shore.
What I'm looking to do is reverse the n return function, so when i echo the file with something like this
echo -aoE '([a-zA-Z])1,5' file
output
My
name
is
nick
rock
and
i
live
by
the
sea
shore.
I'll get this instead
My name is nick rock and i live by the sea shore
command-line text-processing
This question already has an answer here:
How can I print multiline output on the same line?
8 answers
This is related to a question i asked in overflow, It remains unanswered so i though I'd try asking it in segments
My objective is to return the special n function, If i were to run
echo -e "My name is nnick rock and i nlive by the sea shore." > file
Then when i cat that file you get something like this
My name is
nick rock and i
live by the sea shore.
What I'm looking to do is reverse the n return function, so when i echo the file with something like this
echo -aoE '([a-zA-Z])1,5' file
output
My
name
is
nick
rock
and
i
live
by
the
sea
shore.
I'll get this instead
My name is nick rock and i live by the sea shore
This question already has an answer here:
How can I print multiline output on the same line?
8 answers
command-line text-processing
edited May 29 at 8:37
muru
128k19270460
128k19270460
asked May 29 at 8:28
hello moto
3851315
3851315
marked as duplicate by Sergiy Kolodyazhnyy
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jun 1 at 0:07
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Sergiy Kolodyazhnyy
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jun 1 at 0:07
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
1
down vote
accepted
What you're looking for is
$ tr 'n' ' ' < file
My name is nick rock and i live by the sea shore.
tr
utility is for translating sets of characters, in this there's only one character n
in SET1 and space in SET2. As for < file
, that just redirects the file into program's stdin stream.
But if for some reason you need a shell-only way, then this is sufficient:
$ while IFS= read -r line || [ -n "$line" ]; do printf "%s " "$line" ; done < file
My name is nick rock and i live by the sea shore.
add a comment |Â
up vote
2
down vote
you can use this command line, it's an improvement of @Sergiv Kolodyazhnyy which print the n
at the right place
while IFS= read -r line || [ -n "$line" ]; do printf "%s " "$line" ; printf "n" ; done < test.txt
(sorry to not be able to comment)
add a comment |Â
up vote
2
down vote
You can also echo unquoted command-substitution:
echo $(<infile)
I like this one, but one should be aware that this will replace every sequence of characters in$IFS
(usually space,newline,tab) by one space character.
â danzel
May 29 at 11:26
.... which is how word spliting is happening here
â Ã±ÃÂsýù÷
May 29 at 12:02
add a comment |Â
up vote
1
down vote
Here are some options:
using
awk
, with an unset record separator (aka 'paragraph mode') and the default field separatorawk -vRS= '$1=$1 1' file
My name is nick rock and i live by the sea shore.using
xargs
with no explicit command$ xargs < file
My name is nick rock and i live by the sea shore.using
fmt
from GNU coreutils:$ fmt file
My name is nick rock and i live by the sea shore.
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
What you're looking for is
$ tr 'n' ' ' < file
My name is nick rock and i live by the sea shore.
tr
utility is for translating sets of characters, in this there's only one character n
in SET1 and space in SET2. As for < file
, that just redirects the file into program's stdin stream.
But if for some reason you need a shell-only way, then this is sufficient:
$ while IFS= read -r line || [ -n "$line" ]; do printf "%s " "$line" ; done < file
My name is nick rock and i live by the sea shore.
add a comment |Â
up vote
1
down vote
accepted
What you're looking for is
$ tr 'n' ' ' < file
My name is nick rock and i live by the sea shore.
tr
utility is for translating sets of characters, in this there's only one character n
in SET1 and space in SET2. As for < file
, that just redirects the file into program's stdin stream.
But if for some reason you need a shell-only way, then this is sufficient:
$ while IFS= read -r line || [ -n "$line" ]; do printf "%s " "$line" ; done < file
My name is nick rock and i live by the sea shore.
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
What you're looking for is
$ tr 'n' ' ' < file
My name is nick rock and i live by the sea shore.
tr
utility is for translating sets of characters, in this there's only one character n
in SET1 and space in SET2. As for < file
, that just redirects the file into program's stdin stream.
But if for some reason you need a shell-only way, then this is sufficient:
$ while IFS= read -r line || [ -n "$line" ]; do printf "%s " "$line" ; done < file
My name is nick rock and i live by the sea shore.
What you're looking for is
$ tr 'n' ' ' < file
My name is nick rock and i live by the sea shore.
tr
utility is for translating sets of characters, in this there's only one character n
in SET1 and space in SET2. As for < file
, that just redirects the file into program's stdin stream.
But if for some reason you need a shell-only way, then this is sufficient:
$ while IFS= read -r line || [ -n "$line" ]; do printf "%s " "$line" ; done < file
My name is nick rock and i live by the sea shore.
answered May 29 at 8:33
![](https://i.stack.imgur.com/U1Jy6.jpg?s=32&g=1)
![](https://i.stack.imgur.com/U1Jy6.jpg?s=32&g=1)
Sergiy Kolodyazhnyy
63.9k9127274
63.9k9127274
add a comment |Â
add a comment |Â
up vote
2
down vote
you can use this command line, it's an improvement of @Sergiv Kolodyazhnyy which print the n
at the right place
while IFS= read -r line || [ -n "$line" ]; do printf "%s " "$line" ; printf "n" ; done < test.txt
(sorry to not be able to comment)
add a comment |Â
up vote
2
down vote
you can use this command line, it's an improvement of @Sergiv Kolodyazhnyy which print the n
at the right place
while IFS= read -r line || [ -n "$line" ]; do printf "%s " "$line" ; printf "n" ; done < test.txt
(sorry to not be able to comment)
add a comment |Â
up vote
2
down vote
up vote
2
down vote
you can use this command line, it's an improvement of @Sergiv Kolodyazhnyy which print the n
at the right place
while IFS= read -r line || [ -n "$line" ]; do printf "%s " "$line" ; printf "n" ; done < test.txt
(sorry to not be able to comment)
you can use this command line, it's an improvement of @Sergiv Kolodyazhnyy which print the n
at the right place
while IFS= read -r line || [ -n "$line" ]; do printf "%s " "$line" ; printf "n" ; done < test.txt
(sorry to not be able to comment)
answered May 29 at 8:41
damadam
800216
800216
add a comment |Â
add a comment |Â
up vote
2
down vote
You can also echo unquoted command-substitution:
echo $(<infile)
I like this one, but one should be aware that this will replace every sequence of characters in$IFS
(usually space,newline,tab) by one space character.
â danzel
May 29 at 11:26
.... which is how word spliting is happening here
â Ã±ÃÂsýù÷
May 29 at 12:02
add a comment |Â
up vote
2
down vote
You can also echo unquoted command-substitution:
echo $(<infile)
I like this one, but one should be aware that this will replace every sequence of characters in$IFS
(usually space,newline,tab) by one space character.
â danzel
May 29 at 11:26
.... which is how word spliting is happening here
â Ã±ÃÂsýù÷
May 29 at 12:02
add a comment |Â
up vote
2
down vote
up vote
2
down vote
You can also echo unquoted command-substitution:
echo $(<infile)
You can also echo unquoted command-substitution:
echo $(<infile)
answered May 29 at 11:08
ñÃÂsýù÷
22.8k2191150
22.8k2191150
I like this one, but one should be aware that this will replace every sequence of characters in$IFS
(usually space,newline,tab) by one space character.
â danzel
May 29 at 11:26
.... which is how word spliting is happening here
â Ã±ÃÂsýù÷
May 29 at 12:02
add a comment |Â
I like this one, but one should be aware that this will replace every sequence of characters in$IFS
(usually space,newline,tab) by one space character.
â danzel
May 29 at 11:26
.... which is how word spliting is happening here
â Ã±ÃÂsýù÷
May 29 at 12:02
I like this one, but one should be aware that this will replace every sequence of characters in
$IFS
(usually space,newline,tab) by one space character.â danzel
May 29 at 11:26
I like this one, but one should be aware that this will replace every sequence of characters in
$IFS
(usually space,newline,tab) by one space character.â danzel
May 29 at 11:26
.... which is how word spliting is happening here
â Ã±ÃÂsýù÷
May 29 at 12:02
.... which is how word spliting is happening here
â Ã±ÃÂsýù÷
May 29 at 12:02
add a comment |Â
up vote
1
down vote
Here are some options:
using
awk
, with an unset record separator (aka 'paragraph mode') and the default field separatorawk -vRS= '$1=$1 1' file
My name is nick rock and i live by the sea shore.using
xargs
with no explicit command$ xargs < file
My name is nick rock and i live by the sea shore.using
fmt
from GNU coreutils:$ fmt file
My name is nick rock and i live by the sea shore.
add a comment |Â
up vote
1
down vote
Here are some options:
using
awk
, with an unset record separator (aka 'paragraph mode') and the default field separatorawk -vRS= '$1=$1 1' file
My name is nick rock and i live by the sea shore.using
xargs
with no explicit command$ xargs < file
My name is nick rock and i live by the sea shore.using
fmt
from GNU coreutils:$ fmt file
My name is nick rock and i live by the sea shore.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Here are some options:
using
awk
, with an unset record separator (aka 'paragraph mode') and the default field separatorawk -vRS= '$1=$1 1' file
My name is nick rock and i live by the sea shore.using
xargs
with no explicit command$ xargs < file
My name is nick rock and i live by the sea shore.using
fmt
from GNU coreutils:$ fmt file
My name is nick rock and i live by the sea shore.
Here are some options:
using
awk
, with an unset record separator (aka 'paragraph mode') and the default field separatorawk -vRS= '$1=$1 1' file
My name is nick rock and i live by the sea shore.using
xargs
with no explicit command$ xargs < file
My name is nick rock and i live by the sea shore.using
fmt
from GNU coreutils:$ fmt file
My name is nick rock and i live by the sea shore.
answered May 29 at 10:49
steeldriver
62.1k1196163
62.1k1196163
add a comment |Â
add a comment |Â