Jason94
Jason94

Reputation: 13608

can i do multiple things in one command on linux?

I'm testing something where I'm compiling some code and analysing output with a Perl script.

So first I run make, manually copy & paste the output to errors.txt and then running my Perl script (running: perl analysis.pl) in terminal.

Is there away I can do this just with one line in bash?

Upvotes: 1

Views: 1094

Answers (3)

codaddict
codaddict

Reputation: 455312

You can do:

make > error.txt 2>&1 ; perl analysis.pl

We are redirecting the stdout and stderr of make to a file called error.txt and then irrespective of the make success or failure we are running the Perl script( which knows to read from error.txt)

If you want the Perl script to be run only when make succeeds you can use && in place of ;

Upvotes: 6

tommasop
tommasop

Reputation: 18765

This should be the exact command

make > errors.txt && ./my_perl_script

Upvotes: 1

N 1.1
N 1.1

Reputation: 12534

echo yes && echo youcan

Yes will be echoed first, if it executes fine, then only youcan is echoed, otherwise not.

Upvotes: 2

Related Questions