Sponsored Content
Top Forums Shell Programming and Scripting Need some help with an archive script Post 302416227 by Scott on Sunday 25th of April 2010 05:47:06 PM
Old 04-25-2010
Quote:
Originally Posted by JKMlol
I'm not sure how to solve the $month-1 thingy or the foreach sentence, so I need some help.
Code:
/*

    folders =
        folder1
        folder2
        folder3
        folder4
        folder5

*/

month=`date +%m`
    
if($month == 01) 
{
    prev_month = 12
} else
{
    prev_month = $month-1 // if month == 04, prev_month should return 03
}

foreach($folders as $f)
{
    cp /home/misc/images/($f)/img_($month)*.jpg /home/misc/images/archive/($f)/
    cp /home/misc/images/($f)/img_($prev_month)*.jpg /home/misc/images/archive/($f)/
    // delete all files from /home/misc/images/archive/($f)/ that isn't like `img_($month)*.jpg` or `img_($prev_month)*.jpg`
}

What language is this, actually?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

making a archive script

Hi All: I'm not much of a script writer so I could use your input. Here's the objective... Need a script that will archive (tar) files based on date and then move them into an archive directory. The file names are as follows... S20070101.001 Year month day S20070102.001 As you can see... (1 Reply)
Discussion started by: jimmyc
1 Replies

2. Shell Programming and Scripting

script to archive and purge

Hi, I am writing a shell script for archive data from a table. The design is as follows. Step 1: Execute the select query and extract the data into a text file. Step 2: The primary key for this table is TRACKING_NUM, TRACKING_NUM_SUFFIX, TIMESTAMP_UPDATED. So These three fields will be read... (1 Reply)
Discussion started by: kmanivan82
1 Replies

3. Shell Programming and Scripting

Archive script

hi guru, can advise how to construct a housekeeping script using perl for the following ? find /var/tmp/logs -name "si*" -type f -exec gzip -f {} \; find /var/tmp/logs -name "*.gz" -type f -exec mv -f {} /var/tmp/log \; I found out those are not working in shell at when put them on... (1 Reply)
Discussion started by: rauphelhunter
1 Replies

4. Shell Programming and Scripting

script help .. archive

Hi All We have a landing directory where source system puts files.There are variable number of files and the file names are also varying.Each files successful transmission is identified by a .done file.If file name is xyz.dat then the confirmation file will be xyz.dat.done. I want to... (1 Reply)
Discussion started by: dr46014
1 Replies

5. Shell Programming and Scripting

need help archive script

Hi all, I am new to linux and scripting so please forgive me. I need to create a script that will archive files but the max size of the archive need to be 500mb or under. I know about the archiving with parts but i want all the archives as individual archives. Can anyone point me in the correct... (7 Replies)
Discussion started by: craig0
7 Replies

6. Windows & DOS: Issues & Discussions

Archive Unix script to Batch script

Hi All, I have a requirement to archive processed file and retain the archive based on the quantity.. but this is in windows. I have written a drafted shell script, and would like to have it translated into Batch script.. Please... Below is the drafted shell script ... (2 Replies)
Discussion started by: Dave Null
2 Replies

7. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

8. Shell Programming and Scripting

Image Archive Script

Hello, I am working through a test Linux script from a website, and am running into some issues. The point of the script is to find image files throughout the system, copy them to one centralized directory,ignore duplicate images with the same name, and output a text file of all the images copied.... (3 Replies)
Discussion started by: ComSciguy17
3 Replies

9. Shell Programming and Scripting

Need help in FTP script to archive

Hi Guys, I am unable to archive the FTP files from FTP source path to FTP archive path.Currently i am running this script from the Local server. Can someone help me here. Code: #!/bin/ksh set -x HOST='xxxx' USER='xxxx' PASSWD='xxxx' PORTNO='9999' FILE_NAME=$1 FTP_SRC_PATH=$2... (2 Replies)
Discussion started by: spidy
2 Replies

10. Shell Programming and Scripting

Script to archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies
calendar(1)						      General Commands Manual						       calendar(1)

NAME
calendar - reminder service SYNOPSIS
DESCRIPTION
consults the file in the current directory and prints out lines containing today's or tomorrow's date anywhere in the line. On weekends, ``tomorrow'' extends through Monday. When a command-line argument is present, searches for the file in each user's home directory, and sends any positive results to the user by (see mail(1)). Normally this is done daily in the early morning hours under the control of (see cron(1M)). When invoked by reads the first line in the file to determine the user's environment. Language-dependent information such as spelling and date format (described below) are determined by the user-specified statement in the file. This statement should be of the form where language is a valid language name (see lang(5)). If this line is not in the file, the action described in the section is taken. is concerned with two fields: month and day. A month field can be expressed in three different formats: a string representing the name of the month (either fully spelled out or abbreviated), a numeric month, or an asterisk (representing any month). If the month is expressed as a string representing the name of the month, the first character can be either upper-case or lower-case; other characters must be lower- case. The spelling of a month name should match the string returned by calling (see nl_langinfo(3C)). The day field is a numeric value for the day of the month. Month-Day Formats If the month field is a string, it can be followed by zero or more blanks. If the month field is numeric, it must be followed by either a slash or a hyphen If the month field is an asterisk it must be followed by a slash The day field can be followed immediately by a blank or non-digit character. Day-Month Formats The day field is expressed as a numeral. What follows the day field is determined by the format of the month. If the month field is a string, the day field must be followed by zero or one dot followed by zero or more blanks. If the month field is a numeral, the day field must be followed by either a slash or a hyphen If the month field is an asterisk, the day field must be followed by a slash EXTERNAL INFLUENCES
Environment Variables determines the format and contents of date and time strings when no statement is specified in the file. determines the language in which messages are displayed. If is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty vari- able. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5). International Code Set Support Single- and multi-byte character code sets are supported. EXAMPLES
The following file illustrates several formats recognized by calendar: In the following file, dates are expressed according to European English usage: WARNINGS
To get reminder service, either your calendar must be public information or you must run from your personal file, independent of any run systemwide. Note that if you run yourself, the calendar file need not reside in your home directory. extended idea of ``tomorrow'' does not account for holidays. This command is likely to be withdrawn from X/Open standards. Applications using this command might not be portable to other vendors' platforms. AUTHOR
was developed by AT&T and HP. FILES
to figure out today's and tomorrow's dates SEE ALSO cron(1M), nl_langinfo(3C), mail(1), environ(5). STANDARDS CONFORMANCE
calendar(1)
All times are GMT -4. The time now is 12:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy