Pop current directory until specific file is found

Posted by edarroyo on Super User See other posts from Super User or by edarroyo
Published on 2012-04-14T01:38:07Z Indexed on 2012/04/14 5:32 UTC
Read the original article Hit count: 183

Filed under:

I'm interested in writing a script with the following behavior:

  1. See if a file, build.xml, exists in the current directory, if so run a command supplied through arguments to the script.
  2. If not, pop the current directory and look at the parent. Go to 1.

The script would end once we find the file or we reach the root. Also, once the script finishes and control comes back to the user I want the current directory to be that one where the script was initially l

I'm not very familiar with shell scripting but any help/guidance will be much appreciated.

© Super User or respective owner

Related posts about shell-script