#!/usr/bin/zsh function echo_exists() { if [[ -e "${1:r}.py" ]]; then echo "${1:r}.py" # cat "${1:r}.py" elif [[ -e "${1:h}" ]]; then echo "${1:h}" else echo "${1} - no" fi } typeset -a SEARCH_DIR=("${(@f)"$(<$DOTFILES/bin/jupconf.txt)"}") for _dir in "${SEARCH_DIR[@]}"; do echo_exists $_dir done