1

When I try to pastebin 2 command like this:

echo Merry && echo Christmas | pastebinit

It only pastebins the second command, and gives the first as output:

Merry
http://paste.ubuntu.com/9605648/

Now I could just do:

echo Merry Christmas | pastebinit

And that would work, but I want to run 2 separate commands, and pipe the output to pastebinit, I can't:

sudo apt-get install christmas && sudo apt-get update | pastebinit

does not seem to work.

Eric Carvalho
  • 55,453
Tim
  • 33,500

3 Answers3

4

Wrap it to make a compound command:

{ echo Merry && echo Christmas;} | pastebinit

In general, to pipe the output of multiple commands in sequence to another command, do:

{ cmd1; cmd2; ...;} | cmd

or

(cmd1; ... ) | cmd
Tim
  • 33,500
muru
  • 207,228
0

Is there a reason you couldn't first redirect the output of the two commands into a file (using append for the output of the second command), and then pipe that to pastebinit?

echo Merry > out.txt && echo Christmas >> out.txt && cat out.txt | pastebinit

Maybe redirect stderr to the out file also.

muru
  • 207,228
0

Here follows a work-around to answer the question of "how do I grab complex output on the CLI?"

Should be useful:

thufir@dur:~$ 
thufir@dur:~$ script xmas
Script started, file is xmas
thufir@dur:~$ 
thufir@dur:~$ echo Merry && echo Christmas
Merry
Christmas
thufir@dur:~$ 
thufir@dur:~$ exit
exit
Script done, file is xmas
thufir@dur:~$ 
thufir@dur:~$ cat xmas 
Script started on 2017-10-27 06:37:59-0700
thufir@dur:~$ 
thufir@dur:~$ echo Merry && echo Christmas
Merry
Christmas
thufir@dur:~$ 
thufir@dur:~$ exit
exit

Script done on 2017-10-27 06:38:23-0700
thufir@dur:~$ 
thufir@dur:~$ pastebinit xmas
http://paste.ubuntu.com/25830406/
thufir@dur:~$ 

Here's the pastebin file on ubuntu, as above. Reference man script for how to use typescript.

Note that you can execute scripts, interact, etc. The script command just logs everything into a file. Not quite sure how to make it more readable without futzing with the console/shell configuration...

Basically, if you turn off all colors, etc, it looks better.

Thufir
  • 4,631