samedi 1 juillet 2017

Bash script runs but fails every if statement - help on why?

Working on a simple organizational script to copy data to a new destination. The script runs without generating any errors, but no data actually gets moved. Would love any insight on why this might be! Thx :)

cd $fp

files=(ls)
ls
for file in $(ls)
do
    echo '***moving fldr***'
    cd $fp/$file/mydir
    if [ -d fldr ] ; then
    cp -R fldr $dp/element/ ;
    mv fldr fldr_$file ;
    tar -cvzf fldr_$file.tgz fldr_file ;
    echo '***moved fldr***'
else
    echo '***couldnt move fldr***'
fi
if [ -d dir ] ; then
    echo '***moving dir***'
    cp -R dir $dp/element2/ ;
    mv dir dir_$file ;
    tar -cvzf dir_$file.tgz dir_file ;
    echo '***moved dir***'
else
    echo '***couldnt move dir***'
fi
done

Aucun commentaire:

Enregistrer un commentaire