#! /bin/bash # -- Extract the directory tree with the files needed for this document # -- No call parameters PROG=`basename $0` echo Start $PROG cdir=`pwd` # ========== Help routine start help_dis () { cat < /dev/null if [ "$?" -ne 0 ]; then echo " Error - it seems the command \listfiles was not used" exit fi n1=`cat $flog | grep -n 'File List' | cut -d: -f1` # let $((n1++)) nt=`cat $flog | wc -l` ne1=`expr $nt - $n1` tail -n $ne1 $flog > tmp1.txt cat tmp1.txt | grep '\*\*\*\*\*' > /dev/null if [ "$?" -ne 0 ]; then echo " Error - was the command \listfiles used? No trailer stars found" exit fi n2=`cat tmp1.txt | grep -n '\*\*\*\*\*' | cut -d: -f1` let $((n2--)) head -n $n2 tmp1.txt | awk 'NF == 1 {print}' > tmp2.txt # # -- Extract the files to another directory # edir=extract if test -d $edir ; then rm -r $edir fi mkdir $edir # # -- Define the possible source directories # nd=3 declare -a dirn a=`pwd` nam=`basename $a` cd ../../src a=`pwd` dirn[1]=$a cd texnical a=`pwd` dirn[2]=$a cd ../mains/$nam a=`pwd` dirn[3]=$a cd $cdir cp -a *.bbl $edir/main.bbl cp -a ../../src/mains/$nam/main.tex $edir/ for f in `cat tmp2.txt`; do find=0 id=0; while let $((id++)); [ $id -le $nd ]; do d=${dirn[$id]} ff=$d/$f fb=`basename $f` if test -e $ff ; then if [ "$fb" == "$f" ]; then cp -a $ff $edir/ else dirf=`dirname $f` # echo $edir/$dirf if ! test -d $edir/$dirf; then mkdir -p $edir/$dirf fi cp -a $ff $edir/$dirf/ fi # ls -alF $ff let $((find++)) fi done if [ $find -eq 0 ]; then echo Missing file $f fi done echo Directory extract is created rm tmp1.txt rm tmp2.txt