-1

I need to run many commands on sequence like 5 or 10. But they all deal with paths so they are very long like 90 characters each so && won't work probably.

Is there any workaround ?

I want then to only run after the one finished and succeeded.

  • Short answer, most likely, yes (as a shell script) - but more information would help a lot. Are the commands all know? Do they have common sections? Could you update the question to include a sample of the commands? – Tigger Apr 13 '17 at 10:55
  • 1
    90 characters is not very long at all. What do you mean by "won't work probably"? Have you tried it? Did it not work? I see absolutely no reason for this not to work. – egmont Apr 13 '17 at 11:38
1

Put them line by line in a shell script, ending each line with a \ (which will escape the newline):

#!/bin/bash

command1 /very/long/path/to/directory && \
command2 /another/very/long/path/to/directory && \
command3 /and/another/very/long/path/to/another/directory && \
echo "Command sequence finished succesfully"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.