Get Help And Discuss STEM Concepts From Math To Data Science & Financial Literacy
STEM Gender Equality | Join us on ZOOM | Spreading Mathematical Happiness | Join Us on Slack

MathsGee is free of annoying ads. We want to keep it like this. You can help with your DONATION

0 like 0 dislike
20 views
Execute combine multiple shell commands in one line.
in Computer Science by Diamond (51,000 points) | 20 views

1 Answer

0 like 0 dislike

If you want to execute each command only if the previous one succeeded, then combine them using the && operator:

cd /my_folder && rm *.jar && svn co path to repo && mvn compile package install

If one of the commands fails, then all other commands following it won't be executed.

If you want to execute all commands regardless of whether the previous ones failed or not, separate them with semicolons:

cd /my_folder; rm *.jar; svn co path to repo; mvn compile package install

In your case, I think you want the first case where execution of the next command depends on the success of the previous one.

You can also put all commands in a script and execute that instead:

#! /bin/sh
cd /my_folder \
&& rm *.jar \
&& svn co path to repo \
&& mvn compile package install
by Diamond (51,000 points)

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
0 answers
asked Aug 30, 2019 in Computer Science by Tedsf Diamond (51,000 points) | 11 views
0 like 0 dislike
0 answers
0 like 0 dislike
1 answer
asked Aug 29, 2019 in Computer Science by Tedsf Diamond (51,000 points) | 16 views
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Mar 11, 2019 in Data Science by Edzai Zvobwo Bronze Status (8,601 points) | 165 views

Welcome to MathsGee Q&A Bank, Africa’s largest personalized STEM and Financial Literacy education network that helps people find answers to problems, connect with others and take action to improve their outcomes.


MathsGee Q&A is the STEM and Financial Literacy knowledge-sharing community where students and experts put their heads together to crack their toughest questions.


MathsGee is free of annoying ads. We want to keep it like this. You can help with your DONATION

Enter your email address:

11,765 questions
9,761 answers
100 comments
10,513 users