Sponsored Content
Top Forums Shell Programming and Scripting Zip a list of specific files to an archive Post 302628931 by Biggreuda on Tuesday 24th of April 2012 06:45:26 AM
Old 04-24-2012
What the... o_0
What is this place?

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! Smilie

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? Smilie
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.
Code:
ArchiveName="$Criteria-stuff-`date +'%d.%m.%Y'`"
ArchiveFiles=""
for i in $Criteria; do 
    FileName="$i"_stuff_`date +'%d%m%Y'`.csv
        
    Subject="$i-stuff `date +'%d.%m.%Y'`"

    if [ -s /output/$FileName ]; then 
    if [ "$P_PASSWORT" != "" ]
    then        
        zip -l -j -P $P_PASSWORT /output/$FileName.zip /output/$FileName
        FileName=$FileName.zip
        
        if [ "$P_RECEIVER" != "" ]; then
            ArchiveFiles="$ArchiveFiles /output/$FileName"
        fi
    fi
    
    if [ "$P_FTP_SERVER_ID" != "" ]; then
        # [internal code for ftp-upload]
    fi
     fi
done

    if [ "$P_RECEIVER" != "" ]; then
        tar -czf $ArchiveName $ArchiveFiles
        send_mail "$Sender" "$P_RECEIVER" "$Subjekt" "" /output/$ArchiveName $CommandFileName  || { send_mail "$Sender" "$P_ERROR_RECEIVER_MAIL" "$Subjekt" "Error in JOB --> BLA_CUSTOM (FileName: $FileName, stuff: $Criteria). Please Check!"; echo "File couldn't be sent. Error code: $?"; Err_code=1; }
    fi


Last edited by Biggreuda; 04-24-2012 at 08:24 AM.. Reason: Update
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Is extracting specific files from a zip file possible?

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)
Discussion started by: HLee1981
1 Replies

2. AIX

Updating a File in a Zip Archive

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)
Discussion started by: dbridle
6 Replies

3. UNIX for Dummies Questions & Answers

tar archive with including specific patern files

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)
Discussion started by: john.gelburg
1 Replies

4. UNIX for Dummies Questions & Answers

unzip .zip file and list the files included in the .zip archive

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)
Discussion started by: oracledev
5 Replies

5. Shell Programming and Scripting

Read specific file from a zip archive without extracting

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)
Discussion started by: sridharg
4 Replies

6. Shell Programming and Scripting

how to remove absolute paths from zip archive

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)
Discussion started by: mirfan
4 Replies

7. Shell Programming and Scripting

List files with Date Range and Zip it

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)
Discussion started by: nokiak810
2 Replies

8. Shell Programming and Scripting

Specific file list to be zip

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)
Discussion started by: jagkoth
11 Replies

9. Shell Programming and Scripting

Find all the files under a specific directory and zip them into a single file.

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)
Discussion started by: rudoraj
3 Replies

10. UNIX for Beginners Questions & Answers

How to zip csv files having specific pattern in a directory using UNIX shell script?

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)
Discussion started by: Balraj
4 Replies
rb(3erl)						     Erlang Module Definition							  rb(3erl)

NAME
rb - The Report Browser Tool DESCRIPTION
The Report Browser (RB) tool makes it possible to browse and format error reports written by the error logger handler log_mf_h . EXPORTS
filter(Filters) filter(Filters, Dates) Types Filters = [filter()] filter() = {Key, Value} | {Key, Value, no} | {Key, RegExp, re} | {Key, RegExp, re, no} Key = term() Value = term() RegExp = string() | {string, Options} | mp(), {mp(), Options} Dates = {DateFrom, DateTo} | {DateFrom, from} | {DateTo, to} DateFrom = DateTo = {date(), time()} date() and time() are the same type as in the This function displays the reports that match the provided filters. When a filter includes the no atom it will exclude the reports that match that filter. The reports are matched using the proplists module. The report must be a proplist to be matched against any of the filters() . If the filter is of the form {Key, RegExp, re} the report must contain an element with key = Key and Value must match the RegExp regular expression. If the Dates parameter is provided, then the reports are filtered according to the date when they occurred. If Dates is of the form {DateFrom, from} then reports that occurred after DateFrom are displayed. If Dates is of the form {DateTo, to} then reports that occurred before DateTo are displayed. If two Dates are provided, then reports that occurred between those dates are returned. If you only want to filter only by dates, then you can provide the empty list as the Filters parameter. See rb:grep/1 for more information on the RegExp parameter. grep(RegExp) Types RegExp = string() | {string, Options} | mp(), {mp(), Options} All reports containing the regular expression RegExp are printed. RegExp can be a string containing the regular expression; a tuple with the string and the options for compilation; a compiled regu- lar expression; a compiled regular expression and the options for running it. Refer to the module re and specially the function re:run/3 for a definition of valid regular expressions and options. h() help() Prints the on-line help information. list() list(Type) Types Type = type() type() = crash_report | supervisor_report | error | progress This function lists all reports loaded in the rb_server . Each report is given a unique number that can be used as a reference to the report in the show/1 function. If no Type is given, all reports are listed. rescan() rescan(Options) Types Options = [opt()] Rescans the report directory. Options is the same as for start() . show() show(Report) Types Report = int() | type() If a type argument is given, all loaded reports of this type are printed. If an integer argument is given, the report with this ref- erence number is printed. If no argument is given, all reports are shown. start() start(Options) Types Options = [opt()] opt() = {start_log, FileName} | {max, MaxNoOfReports} | {report_dir, DirString} | {type, ReportType} | {abort_on_error, Bool} FileName = string() | standard_io MaxNoOfReports = int() | all DirString = string() ReportType = type() | [type()] | all Bool = true | false The function start/1 starts the rb_server with the specified options, while start/0 starts with default options. The rb_server must be started before reports can be browsed. When the rb_server is started, the files in the specified directory are scanned. The other functions assume that the server has started. {start_log, FileName} starts logging to file. All reports will be printed to the named file. The default is standard_io . {max, MaxNoOfReports} . Controls how many reports the rb_server should read on start-up. This option is useful as the directory may contain 20.000 reports. If this option is given, the MaxNoOfReports latest reports will be read. The default is 'all'. {report_dir, DirString} . Defines the directory where the error log files are located. The default is {sasl, error_logger_mf_dir} . {type, ReportType} . Controls what kind of reports the rb_server should read on start-up. ReportType is a supported type, 'all', or a list of supported types. The default is 'all'. {abort_on_error, Bool} . This option specifies whether or not logging should be aborted if rb encounters an unprintable report. (You may get a report on incorrect form if the error_logger function error_msg or info_msg has been called with an invalid format string). If Bool is true , rb will stop logging (and print an error message to stdout) if it encounters a badly formatted report. If logging to file is enabled, an error message will be appended to the log file as well. If Bool is false (which is the default value), rb will print an error message to stdout for every bad report it encounters, but the logging process is never aborted. All printable reports will be written. If logging to file is enabled, rb prints * UNPRINTABLE REPORT * in the log file at the location of an unprintable report. start_log(FileName) Types FileName = string() Redirects all report output from the RB tool to the specified file. stop() Stops the rb_server . stop_log() Closes the log file. The output from the RB tool will be directed to standard_io . Ericsson AB sasl 2.1.9.3 rb(3erl)
All times are GMT -4. The time now is 12:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy