i've got the following problem:
We've got a shell-script, that creates some different files based on several criteria given, using a sql-script.
After creating, those files are individually zipped and stored, then sent to a ftp-server.
This is all working since 2010, but now they have to be send via e-mail, too.
This wouldn't be a problem, but there are about 40 files created in every run, and so are 40 e-mails sent.
Is it possible to store all the filenames into a variable while they are created in the loop and then zip them into one file, before sending the e-mail?
To be honest, i've never really worked with shell myself and i'm asking a colleague as a favor. I couldn't find a solution via google and this forum seems to be nice
She has to manually sort those e-mails every day, if i can't find a solution...
Thanks in advance!
Edit:
well, i think some of the actual code might help...
This is the important part, only slightly changed
Last edited by Biggreuda; 04-24-2012 at 07:28 AM..
-z is a GNU extension to the tar command
will create a single archive tarball (A gzipped tape archive) of the 40 files, the files can be listed and individual files can be extracted from the archive or the whole archive un-bundled
If it is in a loop, create a tar archive and use the -r switch to add the other files to the archive file. When done, zip them and send them on their way.
If they are the sole inhabitants of a directory or can be easily specified by a their filenames, just create a tar archive on them directly, zip and mail them...
I didn't expect an answer until tomorrow!
Wow, thanks for the fast reply, i'll read myself into those commands and try to create a test without crashing our system.
Thank you both very much!
Edit:
I tried to modify the example-code from above the way i think would be the easiest (for me).
Am i on the right path?
It's kinda difficould to actually test it, since the script runs only once a day in the early morning and tomorrow i'm at school, so i won't implement it before thursday.
Last edited by Biggreuda; 04-24-2012 at 08:24 AM..
Reason: Update
I have files in a Linux directory . Some of the file is listed below
-rw-rw-r--. 1 roots roots 0 Dec 23 02:17 zzz_123_00000_A_1.csv
-rw-rw-r--. 1 roots roots 0 Dec 23 02:18 zzz_121_00000_A_2.csv
-rw-rw-r--. 1 roots roots 0 Dec 23 02:18 zzz_124_00000_A_3.csv
drwxrwxr-x. 2 roots roots 6 Dec 23... (4 Replies)
Hi,
Is there a way to find all the files from a specific location and then zip them into a single file, even if they are in multiple directories? (3 Replies)
Hi,
I need a specific list of files to be zip automatically. based on the criteria
Criteria:
1. It should not be the current file and not less than 10 files
e.g in a folder contails 100 files
jan 50 -> contains ->45 zip files e.g. XXX.gz 5 normal log files e.g XXX.log
... (11 Replies)
Hi all,
I am using the below script which display the files in the folder with the date range we specify. I want to add extra functionality that,
The listing files should be zipped using gzip. I tried to add exec gzip at the last line but it is not working.
Suggestions please.
... (2 Replies)
Hi,
I need to write an bash script which works like it can copy files from remote machine through ssh to the server where script is running in zip format with the structure i want. I don't want to get absolute path in zip archive. Please let me know how it can be possible.
ssh... (4 Replies)
Hi All,
I would like to extract specific file from a zip archive.
I have a zip archive "sample.zip".
sample.zip contains few text files and images... text1.txt, text2.txt, pic.jpg etc...
I need to read specific file "text2.txt" from "sample.zip" WITHOUT EXTRACTING the zip file.
... (4 Replies)
Hello,
I am trying to return the name of the resulting file from a .zip archive file using unix unzip command.
unzip c07212007.cef7081.zip
Archive: c07212007.cef7081.zip
SecureZIP for z/OS by PKWARE
inflating: CEP/CEM7080/PPVBILL/PASS/G0063V00
I used the following command to unzip in... (5 Replies)
Hi,
I need to create recursive tar archive, while I put there only files of type a*.txt.
Without file filtering the command is: tar cfzf test.tar.gz test_tar/
How I include the switch for including only files with pattern a*.txt ?
Thanks a lot! (1 Reply)
Hello everyone,
I have a script that pulls a text file out of a zip archive and updates the file. What I need to do is put it back in the zip archive and replace the old one, but I am having no luck.
Everything I search on forums or internet points to the command zip, that command is not... (6 Replies)
If a zip file contains several zip files, but if the file names of the files needed are known, is there a variation of the unzip command that will allow those few (individual) files to be extracted?
---
Example:
Zip file name: zip.zip
unzip -l zip.zip will display file01, file02, file03, etc.... (1 Reply)