Sponsored Content
Top Forums Shell Programming and Scripting Need script to select multiple files from archive directory based on the date range Post 302388923 by rdcwayx on Friday 22nd of January 2010 12:45:18 AM
Old 01-22-2010
Code:
Not tested:

#! /usr/bin/bash

BASE=/projects/home01/archive
DEST=/tmp

for file in `find $BASE -type f -name "*.txt"`
do
   date=$(echo $FILE|awk -F[\/_] '{print $(NF-1)}')
   if [ "$date" > "$1" && "$date" < "$2" ] ; then 
       mv $file $DEST/$file
   fi
done

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

2. Programming

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

3. Shell Programming and Scripting

Help with Archiving multiple files based on name and date

Dear Gurus, I am a novice in shell scripts. I have a requirement where I need to move files every day from Current Folder to Archive folder. Daily I will be receiving 5 files in the folder - /opt/data/feeds/. The feeds folder has two sub-folders - Current and Archive. For example the... (25 Replies)
Discussion started by: shankar1dada
25 Replies

4. Emergency UNIX and Linux Support

How to move files from a directory which falls between Date Range?

Hi All, I am trying to to move files from a directory to another which falls from Current day - 7 days. The files are in zipped format with dates appended on it. Can you pls help me as this came as a immediate change before the production Release planned next week. Pls let me know if... (11 Replies)
Discussion started by: dsfreddie
11 Replies

5. Shell Programming and Scripting

Moving files from one directory to another based on 2 date variables

Hi All, I am currently coding for a requirement(LINUX OS) where I am supposed to move a file (Lets Call it Employee.txt) from Directory A to Directory B based on 2 date fields as below, Date_Current = 20120620 Date_Previous = 20120610 Source Directory : /iis_data/source Target... (11 Replies)
Discussion started by: dsfreddie
11 Replies

6. Shell Programming and Scripting

Move files from one directory to another based on creation/modification date

Hi All, Really stuck up with a requirement where I need to move a file (Lets say date_Employee.txt--the date will have different date values like 20120612/20120613 etc) from one directory to another based on creation/modification dates. While visiting couple of posts, i could see we can... (3 Replies)
Discussion started by: dsfreddie
3 Replies

7. UNIX for Dummies Questions & Answers

Select all files in a folder based on creation date (ls command)

Hi All, <Re-posting in Correct group> I'm trying to select all the files in a folder that starts with a particular name format and are created in a gven date range using 'ls' command...but i'm not successful.... Example : I'm trying to see all the text files in a folder who names start... (6 Replies)
Discussion started by: Satya C1
6 Replies

8. UNIX for Dummies Questions & Answers

Find the count of files by last created date based on the given date range

My unix version is IBM AIX Version 6.1 I tried google my requirement and found the below answer, find . -newermt “2012-06-15 08:13" ! -newermt “2012-06-15 18:20" But newer command is not working in AIX version 6.1 unix I have given my requirement below: Input: atr files: ... (1 Reply)
Discussion started by: yuvaa27
1 Replies

9. UNIX for Beginners Questions & Answers

Searching for a files based on current date directory

Hi All, I've been trying to do some recursive searching but not been very successful. Can someone please help. Scenario: I have directory structure /dir1/dir2/dir3/ 2019/ 11/ 17 18 19 20 so what I want to do is run a script and as its 2019/11/18/ today it would go and only search... (3 Replies)
Discussion started by: israr75
3 Replies
shar(1) 						      General Commands Manual							   shar(1)

NAME
shar - make a shell archive package SYNOPSIS
[options] [file|dir] ... package DESCRIPTION
The command bundles the named files and directories into a single distribution package suitable for mailing or moving. The files can con- tain any data, including executables. The resulting package, written to standard output, is a shell script file that can be edited (to add messages at the beginning, etc.). To unpack package, use the command with the package name as an argument as follows: When unpacking, the files and directories in package are written to the path names recorded in the archive. If a directory is specified and the option is not given, all files beneath that directory are archived. If a special file is specified, the appropriate commands are emitted to recreate the file (see mknod(1M)). protects the contained files from mail processing, if necessary, by inserting an @ character at the beginning of each line. If the file contains unusual data, the data is transformed into format, and a script is included in package so that the package can still be unpacked correctly by See WARNINGS for more information about mailers and file modifications. Access modes are preserved for both directories and files. Options recognizes the following options: Assume that files can be shipped, regardless of their contents; do not protect them specially. is conservative, and might decide to a file containing special characters (such as Ctrl-G) that the user knows do not need protection. Suppress warning messages regarding optional access control list entries. does not archive optional access control list entries in a file's access control list (see acl(5)). Normally, a warning message is printed for each file having optional access control list entries. Archive files under their base names, regardless of the original path names specified. The contents are thus unpacked into the current directory instead of to the originally specified path names. This allows you to archive files from many directories but unpack them into a single directory. It also allows you to unpack, for example, into instead of overwriting the original one in Append to the package a simple data-integrity check using to ensure that the contents were not damaged in transit (see wc(1)). This check is performed automatically after unpack- ing. Also see WARNINGS below. Insert a line of the form before the archive. If a directory is specified, do not transmit its contents, but rather only create the empty directory. Cause the archive to contain code that notifies the user if his or her current directory is not the same as dir, which must be an absolute path. If the user is not in dir, the unpacking can be continued by responding to the archive's question. Cause the archive to contain code that prevents from unpacking files that would overwrite existing files. Read a list of file names from file and archive those files as if they were given as arguments. Follow symbolic links as if they were normal files or directories. If this option is not specified, archives the link. Retain modification and access times on files when they are unpacked. Preserve user and group ownership on files and directories. Cause the archive to contain code requiring that the user unpacking it be This is useful for processing system archives. Perform error checking using (see sum(1)). Both and can be specified for better error checking. Also see WARNINGS below. Write diagnostics and messages directly to your terminal instead of to the standard error. This is useful when invoking from programs (such as that normally combine standard error with standard output. Specifying also invokes the (verbose) option. Assume that the remote site has for unpacking. If this option is not specified, a version of is sent and compiled if any non-ASCII files are archived. Announce archived file names as they are packed. The option determines the destination for these announcements. Compress files using (see compress(1)). Most options are flagged in the header of the resulting package, thereby recording the format of the archive. The name of the archiver, system, and time/date of the archive are also recorded in the header. EXAMPLES
To archive all files under your home directory, type: or To preserve your directory, type: To send your newest programs in directory in your home directory to a friend, type: RETURN VALUE
returns zero if successful; nonzero if problems with arguments occur. DIAGNOSTICS
If the option is specified, refuses to archive directories. WARNINGS
The modification and access time restoration does not take time zones into account. Files with newline characters in their names scramble the table of contents. Non-ASCII files with white space in their names do not unpack. If a mailer such as elm(1) is used to transfer package to another system and the mailer is configured to expand tabs (by default or other- wise), any file in the archive will be modified if it contains tabs. If the or option is used to create the archive, the data-integrity check will fail during unpacking of any files in package that contain tab characters that were converted to spaces. (Some mailers that expand tabs when transferring files over a network may or may not expand tabs when transferring files to the sender or other users on the local system.) If an editor is used to modify any of the files in package, the data-integrity check will also fail for the files that were changed. AUTHOR
was invented in the public domain. This version of was developed by HP. FILES
For unpacking non-ASCII files if environment variable is set and the directory specified in it is accessible. For unpacking non-ASCII files if environment variable is not set or the directory specified in it is not accessible and directory is accessible. For unpacking non-ASCII files if environment variable is not set or the directory specified in it is not accessible and directory is not accessible. For uncompressing files, which are packed using option, if environment variable is set and the directory specified in it is accessible. For uncompressing files, which are packed using option, if environment variable is not set or the directory specified in it is not accessible and directory is accessi- ble. For uncompressing files, which are packed using option, if environment variable is not set or the directory specified in it is not accessible and directory is not accessible. SEE ALSO
ar(1), compress(1), cpio(1), find(1), tar(1), acl(5). shar(1)
All times are GMT -4. The time now is 07:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy