Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Say I want to modify the latter of some concatenated command line options, is it possible without killing the first command?

Specifically I have compile and run scripts executed thusly:

> compile ; run

The compile is in progress (half way through two hour duration), but new information tells me I don't really want the "run" command to run anymore (it launches a lot of background processes I don't want to go clean up).

Is there a way to accomplish this adjustment or should I just be smarter about how I string together commands in the future?

share|improve this question
    
You should probably be "smarter" and use && instead of ;. –  terdon May 2 '13 at 17:03
    
To clarify, I only know that I want to cancel the run after the compile has been running a while (and I don't want to restart the compile) and I want the run to be cancelled regardless of exit code from the compile. –  owenfi May 2 '13 at 17:07
    
That's the idea, when linked with && the run will not run if the compile is stopped. –  terdon May 2 '13 at 17:10
    
I want the compile to finish for sure, and regardless of compile's exit code I want run not to run. I only came to find this out after an email came in an hour after my command was launched. –  owenfi May 2 '13 at 17:15

1 Answer 1

up vote 3 down vote accepted

Something like

compile && { test -f /path/to/dont_run || run; }

should solve your problem. touch /path/to/dont_run would prevent run from being executed. You can make this more complicated (and more convenient) by e.g. defining a shell function cond_run_cmd which does some check like that, limited to its tty (so that you can have several in parallel) or whatever.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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