refactored
bash script echoes the tailed directories