How to pipe all bash terminal output through command [duplicate]

Clash Royale CLAN TAG#URR8PPP up vote
5
down vote
favorite
This question already has an answer here:
How do I pipe each command given to the shell?
2 answers
I would like to be able to pipe all bash terminal commands through a certain command (for no good reason other than to play a prank on someone). I just want to pipe the stdout of any executed command into a predetermined program without doing anything special.
For example:
If that predetermined program was cowsay
echo "Hello World"
should output
_____________
< Hello World >
-------------
^__^
(oo)_______
(__) )/
||----w |
|| ||
How can I achieve this? (Some of the fun programs I'd like to use to play pranks on others include rev, cowsay, and lolcat)
command-line bash pipe cowsay
marked as duplicate by dessert
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 19:51
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
5
down vote
favorite
This question already has an answer here:
How do I pipe each command given to the shell?
2 answers
I would like to be able to pipe all bash terminal commands through a certain command (for no good reason other than to play a prank on someone). I just want to pipe the stdout of any executed command into a predetermined program without doing anything special.
For example:
If that predetermined program was cowsay
echo "Hello World"
should output
_____________
< Hello World >
-------------
^__^
(oo)_______
(__) )/
||----w |
|| ||
How can I achieve this? (Some of the fun programs I'd like to use to play pranks on others include rev, cowsay, and lolcat)
command-line bash pipe cowsay
marked as duplicate by dessert
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 19:51
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
5
down vote
favorite
up vote
5
down vote
favorite
This question already has an answer here:
How do I pipe each command given to the shell?
2 answers
I would like to be able to pipe all bash terminal commands through a certain command (for no good reason other than to play a prank on someone). I just want to pipe the stdout of any executed command into a predetermined program without doing anything special.
For example:
If that predetermined program was cowsay
echo "Hello World"
should output
_____________
< Hello World >
-------------
^__^
(oo)_______
(__) )/
||----w |
|| ||
How can I achieve this? (Some of the fun programs I'd like to use to play pranks on others include rev, cowsay, and lolcat)
command-line bash pipe cowsay
This question already has an answer here:
How do I pipe each command given to the shell?
2 answers
I would like to be able to pipe all bash terminal commands through a certain command (for no good reason other than to play a prank on someone). I just want to pipe the stdout of any executed command into a predetermined program without doing anything special.
For example:
If that predetermined program was cowsay
echo "Hello World"
should output
_____________
< Hello World >
-------------
^__^
(oo)_______
(__) )/
||----w |
|| ||
How can I achieve this? (Some of the fun programs I'd like to use to play pranks on others include rev, cowsay, and lolcat)
This question already has an answer here:
How do I pipe each command given to the shell?
2 answers
command-line bash pipe cowsay
asked Jun 1 at 16:29
vikarjramun
227212
227212
marked as duplicate by dessert
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 19:51
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 dessert
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 19:51
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 |Â
1 Answer
1
active
oldest
votes
up vote
6
down vote
accepted
exec > >(COMMAND)
Where COMMAND is rev, lolcat or other. This won't work with cowsay.
E.g.
bash-4.3$ exec > >(rev)
bash-4.3$ echo hello
olleh
Explanation:
execnormally replaces the current shell with another process, but if you just give it a redirection like in this case, the redirection will take place for the current shell.>redirect stdout>(COMMAND)input intoCOMMAND
Note that if you have a PROMPT_COMMAND, you should direct it to stderr to avoid the redirected stdout.
Thanks for the explanation, two questions: 1. It works great for tools like lolcat or rev which operate on a line by line basis. But for cowsay, it waits until I press ctrl-d, then outputs everything. How can we make it add an EOF to each command, and spawn a new cowsay each time?
â vikarjramun
Jun 1 at 17:12
@vikarjramun Yeah, I'm having the same problem. Must be a buffering thing. I'm researching it now
â wjandrea
Jun 1 at 17:13
2
@wjandrea Perhaps theunbuffercommand fromexpectcould help.
â PerlDuck
Jun 1 at 17:16
@wjandrea my first thought wasxargs cowsaybut that didn't work. Maybexargs bash -c "echo | cowsay"? I'll try that and see.
â vikarjramun
Jun 1 at 17:30
@PerlDuck I couldn't get it to work. I tried it with and without the-pflag.
â wjandrea
Jun 1 at 18:57
 |Â
show 4 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
exec > >(COMMAND)
Where COMMAND is rev, lolcat or other. This won't work with cowsay.
E.g.
bash-4.3$ exec > >(rev)
bash-4.3$ echo hello
olleh
Explanation:
execnormally replaces the current shell with another process, but if you just give it a redirection like in this case, the redirection will take place for the current shell.>redirect stdout>(COMMAND)input intoCOMMAND
Note that if you have a PROMPT_COMMAND, you should direct it to stderr to avoid the redirected stdout.
Thanks for the explanation, two questions: 1. It works great for tools like lolcat or rev which operate on a line by line basis. But for cowsay, it waits until I press ctrl-d, then outputs everything. How can we make it add an EOF to each command, and spawn a new cowsay each time?
â vikarjramun
Jun 1 at 17:12
@vikarjramun Yeah, I'm having the same problem. Must be a buffering thing. I'm researching it now
â wjandrea
Jun 1 at 17:13
2
@wjandrea Perhaps theunbuffercommand fromexpectcould help.
â PerlDuck
Jun 1 at 17:16
@wjandrea my first thought wasxargs cowsaybut that didn't work. Maybexargs bash -c "echo | cowsay"? I'll try that and see.
â vikarjramun
Jun 1 at 17:30
@PerlDuck I couldn't get it to work. I tried it with and without the-pflag.
â wjandrea
Jun 1 at 18:57
 |Â
show 4 more comments
up vote
6
down vote
accepted
exec > >(COMMAND)
Where COMMAND is rev, lolcat or other. This won't work with cowsay.
E.g.
bash-4.3$ exec > >(rev)
bash-4.3$ echo hello
olleh
Explanation:
execnormally replaces the current shell with another process, but if you just give it a redirection like in this case, the redirection will take place for the current shell.>redirect stdout>(COMMAND)input intoCOMMAND
Note that if you have a PROMPT_COMMAND, you should direct it to stderr to avoid the redirected stdout.
Thanks for the explanation, two questions: 1. It works great for tools like lolcat or rev which operate on a line by line basis. But for cowsay, it waits until I press ctrl-d, then outputs everything. How can we make it add an EOF to each command, and spawn a new cowsay each time?
â vikarjramun
Jun 1 at 17:12
@vikarjramun Yeah, I'm having the same problem. Must be a buffering thing. I'm researching it now
â wjandrea
Jun 1 at 17:13
2
@wjandrea Perhaps theunbuffercommand fromexpectcould help.
â PerlDuck
Jun 1 at 17:16
@wjandrea my first thought wasxargs cowsaybut that didn't work. Maybexargs bash -c "echo | cowsay"? I'll try that and see.
â vikarjramun
Jun 1 at 17:30
@PerlDuck I couldn't get it to work. I tried it with and without the-pflag.
â wjandrea
Jun 1 at 18:57
 |Â
show 4 more comments
up vote
6
down vote
accepted
up vote
6
down vote
accepted
exec > >(COMMAND)
Where COMMAND is rev, lolcat or other. This won't work with cowsay.
E.g.
bash-4.3$ exec > >(rev)
bash-4.3$ echo hello
olleh
Explanation:
execnormally replaces the current shell with another process, but if you just give it a redirection like in this case, the redirection will take place for the current shell.>redirect stdout>(COMMAND)input intoCOMMAND
Note that if you have a PROMPT_COMMAND, you should direct it to stderr to avoid the redirected stdout.
exec > >(COMMAND)
Where COMMAND is rev, lolcat or other. This won't work with cowsay.
E.g.
bash-4.3$ exec > >(rev)
bash-4.3$ echo hello
olleh
Explanation:
execnormally replaces the current shell with another process, but if you just give it a redirection like in this case, the redirection will take place for the current shell.>redirect stdout>(COMMAND)input intoCOMMAND
Note that if you have a PROMPT_COMMAND, you should direct it to stderr to avoid the redirected stdout.
edited Jun 1 at 18:59
answered Jun 1 at 16:39
wjandrea
7,02542054
7,02542054
Thanks for the explanation, two questions: 1. It works great for tools like lolcat or rev which operate on a line by line basis. But for cowsay, it waits until I press ctrl-d, then outputs everything. How can we make it add an EOF to each command, and spawn a new cowsay each time?
â vikarjramun
Jun 1 at 17:12
@vikarjramun Yeah, I'm having the same problem. Must be a buffering thing. I'm researching it now
â wjandrea
Jun 1 at 17:13
2
@wjandrea Perhaps theunbuffercommand fromexpectcould help.
â PerlDuck
Jun 1 at 17:16
@wjandrea my first thought wasxargs cowsaybut that didn't work. Maybexargs bash -c "echo | cowsay"? I'll try that and see.
â vikarjramun
Jun 1 at 17:30
@PerlDuck I couldn't get it to work. I tried it with and without the-pflag.
â wjandrea
Jun 1 at 18:57
 |Â
show 4 more comments
Thanks for the explanation, two questions: 1. It works great for tools like lolcat or rev which operate on a line by line basis. But for cowsay, it waits until I press ctrl-d, then outputs everything. How can we make it add an EOF to each command, and spawn a new cowsay each time?
â vikarjramun
Jun 1 at 17:12
@vikarjramun Yeah, I'm having the same problem. Must be a buffering thing. I'm researching it now
â wjandrea
Jun 1 at 17:13
2
@wjandrea Perhaps theunbuffercommand fromexpectcould help.
â PerlDuck
Jun 1 at 17:16
@wjandrea my first thought wasxargs cowsaybut that didn't work. Maybexargs bash -c "echo | cowsay"? I'll try that and see.
â vikarjramun
Jun 1 at 17:30
@PerlDuck I couldn't get it to work. I tried it with and without the-pflag.
â wjandrea
Jun 1 at 18:57
Thanks for the explanation, two questions: 1. It works great for tools like lolcat or rev which operate on a line by line basis. But for cowsay, it waits until I press ctrl-d, then outputs everything. How can we make it add an EOF to each command, and spawn a new cowsay each time?
â vikarjramun
Jun 1 at 17:12
Thanks for the explanation, two questions: 1. It works great for tools like lolcat or rev which operate on a line by line basis. But for cowsay, it waits until I press ctrl-d, then outputs everything. How can we make it add an EOF to each command, and spawn a new cowsay each time?
â vikarjramun
Jun 1 at 17:12
@vikarjramun Yeah, I'm having the same problem. Must be a buffering thing. I'm researching it now
â wjandrea
Jun 1 at 17:13
@vikarjramun Yeah, I'm having the same problem. Must be a buffering thing. I'm researching it now
â wjandrea
Jun 1 at 17:13
2
2
@wjandrea Perhaps the
unbuffer command from expect could help.â PerlDuck
Jun 1 at 17:16
@wjandrea Perhaps the
unbuffer command from expect could help.â PerlDuck
Jun 1 at 17:16
@wjandrea my first thought was
xargs cowsay but that didn't work. Maybe xargs bash -c "echo | cowsay"? I'll try that and see.â vikarjramun
Jun 1 at 17:30
@wjandrea my first thought was
xargs cowsay but that didn't work. Maybe xargs bash -c "echo | cowsay"? I'll try that and see.â vikarjramun
Jun 1 at 17:30
@PerlDuck I couldn't get it to work. I tried it with and without the
-p flag.â wjandrea
Jun 1 at 18:57
@PerlDuck I couldn't get it to work. I tried it with and without the
-p flag.â wjandrea
Jun 1 at 18:57
 |Â
show 4 more comments