Scripting Question
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
Have a Linux Problem
Linux Forum
- Do you have a Linux Question?
Linux Books
Linux Certification,
System Administration, Programming, Networking Books
Linux Home: Linux
System Administration Hints and Tips
(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
All product names are trademarks of their respective
companies.
The site www.gotothings.com is in no way affiliated with
or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.
|