Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8739107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:52:04+00:00 2026-06-13T10:52:04+00:00

I am trying to merge multiple linux commands in one line to perform deployment

  • 0

I am trying to merge multiple linux commands in one line to perform deployment operation.
For example

cd /my_folder
rm *.jar
svn co path to repo
mvn compile package install
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:52:04+00:00Added an answer on June 13, 2026 at 10:52 am

    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
    

    The backslashes at the end of the line are there to prevent the shell from thinking that the next line is a new command; if you omit the backslashes, you would need to write the whole command in a single line.

    A more convenient way compared to using backslashes and && everywhere is to instruct the shell to exit the script if any of the commands fail. You do that using the set built-in function with the -e argument. With that, you can write a script in a much more natural way:

    #! /bin/sh
    set -e
    
    cd /my_folder
    rm *.jar
    svn co path to repo
    mvn compile package install
    

    Save that to a file, for example myscript, and make it executable:

    chmod +x myscript
    

    You can now execute that script like other programs on the machine. But if you don’t place it inside a directory listed in your PATH environment variable (for example /usr/local/bin, or on some Linux distributions ~/bin), then you will need to specify the path to that script. If it’s in the current directory, you execute it with:

    ./myscript
    

    The commands in the script work the same way as the commands in the first example; the next command only executes if the previous one succeeded. For unconditional execution of all commands, simply don’t call set -e:

    #! /bin/sh
    
    cd /my_folder
    rm *.jar
    svn co path to repo
    mvn compile package install
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to merge 2 simple programs I have made to one .jar.
Well i'm trying to merge multiple PDFs in to one. I gives no errors
I'm trying to merge multiple rows into one column. I have a table: COST_ID
I'm trying to use ILMerge to merge multiple assemblies into one plugin assembly, which
I'm trying to merge multiple assemblies into one as my 'Proxy' assembly for a
I am trying idiomatically merge multiple maps into a single map using clojure. Input
I am trying to merge the data from two tables into one result but
I am trying to merge multiple excel files using DataTable.Merge() option For Each fileName
I am trying to merge two similar tables (not exact) to one table. Getting
I am trying to learn to simplify my code and merge multiple data.frames (>2)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.