4

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?

John
  • 43
  • 4

1 Answers1

4

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'
Eduardo Ivanec
  • 14,531
  • 1
  • 35
  • 42