#!/bin/sh cat book-list | while read buch do i=1 while [ -e "chapters/$buch/$i" ] do echo "chapters/$buch/$i" i=$((i+1)) done done