Hi ,
I want to zip files present in the directories listed under a parent directory without zipping the directory itself
my parent directory path is
/informatica/DGDMN/PowerCenter1011/server/infa_shared/SrcFiles/OTE/Final_Directory
I have the below directories named as 1,2,3,4,5 listed under the parent directory "Final_Directory"
1
2
3
4
5
I want to zip the contents of each of these five directories separately and create 5 separate zipped files in such a way that the directory itself does not get zipped
The code that I used to create 5 zipped files is below. But it creates 5 zipped files along with zipping their folders (1,2,3,4,5).How should I modify this script to create zipped files only for the contents of each of these folders separately without zipping their actual folders?
Please help
cd $final_path ;
for i in */ ;
do zip -r "${i%/}.zip" "$i" ;
done
find <startdir> -type d -exec /path/to/zip {} {}/* \;
Notice, that some versions of the find -command do not allow for multiple instances of the {}-macro and because i do not know which one you are using you will have to find out if yours does or doesn't. In the latter case put the zip -command into a small script to which you pass the {} as argument and call that from the find -command.
cd /path/to/main/dir
for subdir in *
do
pushd $subdir
if [ $? =0 ]
then
tar -cvf ../$subdir.tar .
popd
else
echo "Failed to change to \"$subdir\"" >&2
fi
done
This will safely change into & out of the directories you are working with and create a .tar for each on in the main directory (the big huge path you list) or you could direct them to a specific location if that is better for you.
Telling us "it is not working" will NOT help either you or us. Our respected forum members(MODs-->rbatte1, bakunin) already tried to help you without knowing much information about your system. I would like to request you please let us know all the details about your system eg--> O.S, sample Input_file in code tags more clearly and expected sample output more clearly in code tags along with all the conditions which you want to keep in solution. So that we could try to help and could try to learn/guide on same.
When you say zipping, do you mean the process of:-
compressing the data of a single file?
bunching up lots of files into a single archive?
both at the same time?
Something like tar collects multiple files and puts them into a single convenient archive. Depending on your OS, you might have the -z which will compress them at the same time with gzip It is customary to use a file extension such as .tar.gz or .tgz for such compressed archives.
If you don't have the -z flag, then writing to STDOUT and then piping that through gzip or compress (depending what you have available) can then be directed to a single file.
Have a try with these to see what you can do:-
cd /path/to/source/directory
tar -czvf /path/to/my_data.tgz .
tar -cvf - . | compress > /path/to/my_data.tar.Z
tar -cvf - . | gzip > /path/to/my_data.tar.gz