#!/bin/sh rm -f docdirs touch docdirs for dir in * do if [ -d ${dir} ] then if [ -f ${dir}/main.tex ] then echo ${dir} >> docdirs fi fi done