5

I've discovered the following useful trick for long-running tasks on the command line:

do_some_task && make_a_noise

For instance, on OSX:

do_some_task && say 'done'

However, && means "run the next command if the previous one returned 0 for success". If the first command fails, the second doesn't execute.

Is there a similar operator that means "do this regardless of the previous command's return status"?

18

Yes, the ;:

do_some_task ; say 'done'
  • 2
    or if you want more baroque style: do_some_task && say 'done' || say 'done' :) – lynxlynxlynx Jul 11 '12 at 17:29

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.