Script to Tar file in a specific Directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to Tar file in a specific Directory
# 8  
Old 02-14-2017
Your last sample can be written as
Code:
#!/bin/bash 
LOG_DIRS="/Sandbox/logs1 /Sandbox/logs2 /Sandbox/logs3 /Sandbox/logs4"
for log_dir in $LOG_DIRS
do
  for file in "$log_dir"/*
  do
    # ensure it is a file and not yet gzipped
    if [ -f "$file" ] && [[ $file != *.gz ]]
    then
      gzip "$file"
    fi
  done
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Linux read specific content file from tar.gz files without extracting

hello i wish to write the result of these below conditions in a file: 1. in a specific folder, i have many tar.gz files. 2. each tar.gz file contains ".dat" file in sub folders. 3. i wish to get the full path of these .dat files, if i find in it a specific word ("ERROR24"). 4. all this... (6 Replies)
Discussion started by: jimmyjames9
6 Replies

2. AIX

Making Tar of directory and tar file is going to be placed

Quick question, is it possible to make a Tar of completely directory and placing the tar file in it (will this cause even the tar file to tarred ?) sample: /opt/freeware/bin/tar -cvf - /oracle | gzip > /oracle/backup.tgz will the tar file backup.tgz also include backup.tgz ? i tried... (5 Replies)
Discussion started by: filosophizer
5 Replies

3. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

4. Solaris

HOW TO extract.tar file to specific directory..?

Hi all, In Solaris howto extract tar file to specific folder. This is what we do in Linux, but how to do the same thing in Solaris ? -tar -xzvf /tmp/etc.tar.bz -C /tmp (Will extract in /tmp dir) 3.gzip COMPRESSION AND EXTRACTION -tar -czvf /tmp/etc.tar.bz /etc -du ... (5 Replies)
Discussion started by: manalisharmabe
5 Replies

5. UNIX for Advanced & Expert Users

allow user to use sudo cp on a specific directory and only a specific file

Is there a way to allow a user to use sudo cp on a specific directory and only a specific file? (6 Replies)
Discussion started by: cokedude
6 Replies

6. Shell Programming and Scripting

untar .tar.gz file to a specific file

Hi, I'll get a tarred file from a remote location in the format of .tar.gz which my program needs to un-tar it into a specific destination foler and a file Incoming file/local/server/source/path/remote_file.txt.tar.gz Extracted file/local/server/destination/path/un-tar/stage_file.txt ... (5 Replies)
Discussion started by: dips_ag
5 Replies

7. UNIX for Dummies Questions & Answers

Extracting specific files from a tar file in HP-UX

I have tried: tar -xfv mytarfile.tar archive/tabv/* tar -xfv mytarfile.tar --wildcards 'archive/tabv/*' tar -xf mytarfile.tar -v --wildcards 'archive/tabv/*' tar -xfv mytarfile.tar --wildcards --no-anchored 'archive/tabv/*' tar -xfv mytarfile.tar --wildcards `archive/tabv/*` and none... (5 Replies)
Discussion started by: zapper222
5 Replies

8. Shell Programming and Scripting

Archive directory script with tar/compress

Hi all I need to write a script that archives all files with a certain date in the filename, to another location. It has to run on a AIX using tar/compress or another standard AIX tool. The directory will have x files, each prefixed with a date like yyyymmdd_desc.csv. I need all to... (7 Replies)
Discussion started by: AIXfrog
7 Replies

9. UNIX for Dummies Questions & Answers

tar - restore only file of specific dates

hi there, anybody know if there is any efficient way of restoring only files of specific dates from a tape (with tar command)? :rolleyes: coz the tapes containing few weeks' files, but i need only files of a few days..... any kind feedback is appreciated. Thanks in advanced. (0 Replies)
Discussion started by: newbie168
0 Replies

10. Shell Programming and Scripting

TAR manipulation of file directory

I want to insert file to tar file (by tar command). The file is currently in a diffrenet directory and i want to be saved at the tar file as it was in other directory. I write the script in korn shell. How can i do it? (0 Replies)
Discussion started by: arielromi
0 Replies
Login or Register to Ask a Question
GENPLOTFILES(1) 						      colplot							   GENPLOTFILES(1)

NAME
genplotfiles - utility to help automate creation of collectl plot file from raw ones SYNOPSIS
/opt/hp/colplot/genplotfiles.pl -outdir [-switches] DESCRIPTIONS
This utility is not intended to meet all plot file creation needs, but quite frankly should meet most. Features not provided with this utility are best realized by running collectl directly in playback mode (see collectl -p). It is therefore important to understand what this utility will and will not do for you before building an automation strategy around it. The algorithm used is fairly simple - genplotfiles examines each collectl raw file to see it it falls within the data ranges (if specified) and contains a matching hostname (if specified). If a plot file already exists, the timestamps are compared and the raw file skipped if its newer than the plotfile. Any raw files that pass all these tests are then passed to collectl with their timestamp wildcarded. The result is all raw files for that host/date will be processed. This means if you copy over collectl raw files multiple times over the course of the day using rsync, you can immediately genererate up-to-date plots for them using genplotfiles. Furthermore, you won`t even need any date parameters if the older plot files are alreay up to date. For an example of what a cron job that aggregates multiple collectl logs onto a single system for plotting purposes, see crontab.sh in the same directory as this script. SWITCHES
All switches are optional with the exception of -outdir: -colbin path-to-collectl This points to collectl and is only necessary if /usr/sbin is not in your path or you`ve chosen to install collectl in a non-stan- dard directory. -debug number Primarily for development, will provide intermediate processing information based on its value. See souce for details. -force Always generate plot files even in there is an existing one that is newer than the latest raw file. This will be necessary if you want to rerun this script and just change the value of -subsys. -help Print a summary of available switches. -host string Only process files that contain this string in their hostname portion of the filename. -indir directory Directory where to look for collectl logs. The default is /var/log/collectl and is therefore only necessary if your logs are in a non-standard location. -outdir directory Directory into which to write the plottable files. This field is required. -fromdate date Ignore files with a datestamp in their name less that this value. The default is 20050101 and so defaults to all files. The value of `yesterday` is also recognized to simplify scripts that call this. -thrudate date Ignore files with a datestamp in their name with a datestamp greater than this value. The default is the current day and one can also specify a value of `yesterday`. -subsys string Instead of using the default subsystems for which data was collected, generate output files based on this set. There are basically two reasons for doing this. The first is that you may want to reduce the size of the plot files, though with compression there is rarely much point in this. The second is if you`ve asked collectl to collect summary data but want to plot detail data. See the colplot FAQ for more information. AUTHOR
This program was written by Mark Seger (mjseger@gmail.com). Copyright 2005 Hewlett-Packard Development Company, L.P. SEE ALSO
LOCAL
OCTOBER 2005 GENPLOTFILES(1)