I have a list of scripts./myscript <param> | grep asd./myotherscript <param> <param> > file...How can I automaticaly run another script when one of these command in the list is executed and finished?
Run a script after some command were executed
command line;shell script;terminal
There are multiple ways to automatically execute something after a specific command:functionCreate a function named after your specific command and execute the specific command afterwards. This is in my opinion the simplest and cleanest solution.function myotherscript() {   command myotherscript $@   other_command_to_be_executed}zshWith zsh you can create a precmd function which will be executed before the prompt. This allows you to execute arbitrary other commands but you'll have to determine the executed command yourself. function precmd() {   last_cmd=$(history -1 |  sed -e s/^[ ]*[0-9]*[ ]*//g)   case $last_cmd in   *myscript*) other_command;;   *myotherscript*) other_other_command;;   esac}bashBash has the PROMPT_COMMAND variable allowing you to implement your own precmd function. To use it you have to set it to a command which will be executed before the prompt:PROMPT_COMMAND=${PROMPT_COMMAND};bash_precmdfunction bash_precmd() {  last_command=$(history 1 | sed -e s/^[ ]*[0-9]*[ ]*//g)  case $last_command  in  *pattern*) command ;;  esac}If you are using bash and want to use something like preexec or precmd have a look at precmd and preexec with bash