I am using the below code to close all the FireFox instances in a windows machine. Can this same code used in Mac machine? If not what will be the best approach?
Runtime.getRuntime().exec("taskkill /F /IM FireFox.exe");
Can this same code used in Mac machine?
But this will work:
Runtime.getRuntime().exec("pgrep 'firefox' | xargs kill");
pgrep 'firefox' | xargs kill
pgrep 'firefox' - find all process ids that match processes having firefox in their name.
| xargs kill - Pass all the process IDs found from pgrep as input to the kill command.