Question: I have two python scrips (direct.py and nat.py) and I would like to make a bash script to select which python to start based on my input.

Also, when manually running those py scripts I have input options (0...8,h and q). 
When press 'q' I have sys.exit().

eg:

```
./start.sh and output should be something like:
Chose your mode: (if type nat)
python3 nat.py

```

now python script is displayed and if press q, back to bash to chose option.

Answer: 
In the `zsh` shell, if `$var` is `/1/2/3/4/5/6`, `${var:h1}` is `/`, `${var:h2}` is `/1`, `${var:h3}` is `/1/2` and so on (`h` for *head*, same as is `csh`/`vim`; while the numeric suffix is a `zsh` extension)

So here, to get `/home/user/public_html/projectX` out of `file=/home/user/public_html/projectX/a/b`, it would just be

```
dir=${file:h5}

```

To loop over all the directories that match `/home/*/public_html/*`, that would just be:

```
for dir in /home/*/public_html/*(N/); do
  something with $dir
done

```

(replace `(N/)` with `(N-/)` to also include symlinks to directories; in any case the first `*` will also match symlinks to directories above).

That `(N/)` is a [*glob qualifier*](http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers), a feature specific to `zsh`.
You might want to consider (double) "parameter expansion: Remove matching prefix/suffix pattern":

```
$ path=/home/[username]/public_html/[prjectname]/abc/xyz
$ echo "${path%"${path#/*/*/*/*/}"}"
/home/[username]/public_html/[prjectname]/

```

No external command needed.