23

I have cmd1 and cmd2.

cmd1 && cmd2 will not run cmd2 if cmd1 fails.

cmd1 || cmd2 will run cmd2 if cmd1 fails

How do I run cmd2 regardless of whether cmd1 succeeds or not?

Cheetah
  • 573
  • 2
  • 5
  • 9

1 Answers1

33

To execute cmd2 regardless of whether the previous one result is, separate your command with semicolons or newlines:

cmd1; cmd2

# or
cmd1
cmd2
choroba
  • 45,735
  • 7
  • 84
  • 110
hg8
  • 1,420
  • 3
  • 16
  • 25
  • 10
    You can also use `cmd1 & cmd2`. This way `cmd2` won't wait for `cmd1` to finish before running. – Vinz Sep 29 '15 at 10:17