5

In a bash script I would like to execute multiple commands while keeping a file locked with setlock. Setlock however only supports the following usage:

setlock [-NnXx] [lock file] [command]

Is there a way to wrap multiple commands together besides using a separated script?

1 Answer 1

5

You can use sh as a command, enabling you to use &&, ; or || as usual to chain multiple commands as desired inside single quotes.

For example to run command1 followed by command2 (if the first exits without errors):

setlock lockfile sh -c 'command1 && command2'
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .