I have a small script that finds directories of a given name and then tars them, I would want know how to put the name of the previous directory as part of the tarred file.
Example.
->lukedir
-->luke2.fid
I would like the script to make a file name
lukedir.luke2.fid.tar.gz
Currently I have this script.
find / -type d -name "*.fid" -exec tar zcf {}.tar.gz {} \;
How could I modify it to make it have such naming?
PWD=`pwd`
for dir in `find / -type d -name "*.fid"` ; do
BASENAME=`basename $dir`
DIRNAME=`dirname $dir`
cd $DIRNAME
tar czvf ${BASENAME}.tar $BASENAME
cd $PWD
done
Quick Links:
Do
you have a Linux Question?
Linux Home: Linux System Administration Hints and Tips