This question already has an answer here:
I have a script that I need to run an application which, at the end, changes the working directory. (I'm modifying an ".sh" script and am new to Unix.) I then need to run some commands in that new directory. I won't know what the directory will be before running the application. If I run the script as I would run things myself, the directory doesn't change until after I've run the entire script. I'd like to do this about a dozen times in a row so I'd rather not wait (sometimes hours) for each step to run another separate script myself.
Is there a way to run the application, have the directory change, then run additional work in that directory all in one go?
Edit: Here's the basics of my script. dset takes a parameter (ex. "10") and puts me in a directory. I create a subdirectory "../10" adjacent to it and move files to that new subdirectory.
. dset 10 mkdir ../10 mv tmp.out ../10