Hi I have 4 files in a folder and I am supposed to group and zip them via a mapping file as such:
Group. Filename
-
A.txt
-
B.txt
-
C.txt
-
D.txt
Result should be 2 zip files - 1.zip and 2.zip created with the contents being the text file.
How can this be done via a script?
zaxxon
2
Why do you want to do this via script and not manually?
I am using 4 files as an illustration of what I am trying to achieve. In actual fact I have ard 5000 files
Dimi3
4
By what do you need to group them ? A number of files, or another "mapping" files ?
Hi,
By a mapping file I would need to group them.
I am confused mate!... Need more clarity!
Are the files names like 1.A.txt 2.A.txt or how is it? And on what basis do you need to do the grouping?...
--ahamed
Hello!
The files do not follow any convention. It's from the mapping file that the unix script should find the physical file and group .
In my head, I would reckon the pseudo code will go like this:
- Read the mapping file
- For group 1, get filepath and find the physical files and bunch them together via zip
- For group 2, get filepath and find the physical files and bunch them tog via zip
- Rinse and repeat until EOF encountered in mapping file
awk '{_[$1]=_[$1]" "$2}
END{
for(i in _)
print "tar -cvf "i".tar "_
}' a | while read line;do
eval $line
done