Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Copying files with the latest date Post 79734 by hadarot on Saturday 30th of July 2005 04:26:56 PM
Old 07-30-2005
If the modification times of the files don't necesarilly match the "dates" coded in the filenames, then you have to be a bit more creative. If this is part of a big project that you want automated, you should look into writing a perl script, which would read the directory filenames into an array, and then parse the filenames for substrings (those correspdng to "dates"), and order the array according to these substrings. In this way you can determine the filename corresponding to the most recent date.

Also, as more general advice, rather than making a copy of the most recent file, you should consider creating a symbolic link to it. E.g., in your example above, use:
ln -s bas100e1_jun05 bas100e1

But to get to the real issue: I don't know what you are trying to do with these different files. But if these file represent different versions/revisions of basically the same file, and you are using dates in the filenames to keep track of these revisions, then you are probably WAY better off looking into a version control system. Probably RCS is what you would want to use. Very simple and elegant...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copying files created after a specified date/time

I need to write a script that copies files from one directory to another that were created after "today 6:30". This script will be NOT be ran at the same time each day. any help is appreciated. (2 Replies)
Discussion started by: jm6601
2 Replies

2. Shell Programming and Scripting

Loop through files in dir, omit file with latest date

I want to loop through files in a directory but omit the file with the latest date in my list of files. How would I accomplish this? Thanks (2 Replies)
Discussion started by: stringzz
2 Replies

3. Shell Programming and Scripting

copying the latest file

Hi, I have a problem. I have some text files in a folder. The names can be like: emp_20080307053015.dat emp_20080306053015.dat emp_20080305053015.dat emp_20080304053015.dat The date format appended is like yyyymmdd and timestamp. What i need is i have to copy the latest file every... (12 Replies)
Discussion started by: Aswarth
12 Replies

4. Shell Programming and Scripting

shell script to find latest date and time of the files

Hi everyone, Please help:) I have a list of 1000 different files which comes daily to the directory.Some of the files are not coming to the directory now. I need to write a shell script to find the latest date and time of the files they came to the directory. The files should be unique.... (1 Reply)
Discussion started by: karthicss
1 Replies

5. Shell Programming and Scripting

Copying latest file into a folder

Hello all, this is my first post while i am trying to understand unix. I would basically like to know if i can do this: Lets say i have a folderA and folderB And i save something in folderA Can i make a script that checks folderA latest file, then compares it with the date of latest file in... (16 Replies)
Discussion started by: takissd
16 Replies

6. Shell Programming and Scripting

Copying a directory structure with the latest versions of files

Hello I have three directory structures for code releases. Each directory structure looks like this: bash-3.00$ ls -R | more .: Test_Release_1 Test_Release_2 Test_Release_3 ./Test_Release_1/dbcode: rp_online_import_srdp.pkb-1 srdp_ar_validation.pkb-1... (1 Reply)
Discussion started by: Glyn_Mo
1 Replies

7. Shell Programming and Scripting

How to backup latest date files?

Hi, I have below two situations to handle, 1. I have list of files with file names having date&time. I have to backup to old date files. say I have below files in a directory, 1. XX123_20101004010101.dat 2. XX124_20101004010201.dat 3. XX121_20101003010101.dat 4.... (6 Replies)
Discussion started by: smr_rashmy
6 Replies

8. UNIX for Dummies Questions & Answers

latest files copying over to new path

ls -lrt | nawk -v D="$(date +'%b%e:'| sed 's/ //g')" 'D==$6$7":"{sub(".*"$9,$9);print}' This picks only the latest files created based on the timestamp for that particular day.. how do i copy over the same files to a different location???? (1 Reply)
Discussion started by: win4luv
1 Replies

9. UNIX for Dummies Questions & Answers

Selecting the file of latest Date

Hi Folks, I have one query that there is a folder in which daily several logs files are getting created , I reached to that location through putty but what I observer that 10 files of different date are been created with same name , what I need to see is the latest file ...let say the location is ... (5 Replies)
Discussion started by: KAREENA18
5 Replies

10. Shell Programming and Scripting

Perl : copying only the latest file to other directory

In linux.. In a directory there are 3 files which I want to copy only the latest file (ls -ltr myfiles*.txt|tail -1) to other directory in perl? Could anyone please help me with the code? Regards, J (1 Reply)
Discussion started by: scriptscript
1 Replies
RLOG(1) 						      General Commands Manual							   RLOG(1)

NAME
rlog - print log messages and other information about RCS files SYNOPSIS
rlog [ options ] file ... DESCRIPTION
rlog prints information about RCS files. Pathnames matching an RCS suffix denote RCS files; all others denote working files. Names are paired as explained in ci(1). rlog prints the following information for each RCS file: RCS pathname, working pathname, head (i.e., the number of the latest revision on the trunk), default branch, access list, locks, symbolic names, suffix, total number of revisions, number of revisions selected for print- ing, and descriptive text. This is followed by entries for the selected revisions in reverse chronological order for each branch. For each revision, rlog prints revision number, author, date/time, state, number of lines added/deleted (with respect to the previous revi- sion), locker of the revision (if any), and log message. All times are displayed in Coordinated Universal Time (UTC) by default; this can be overridden with -z. Without options, rlog prints complete information. The options below restrict this output. -L Ignore RCS files that have no locks set. This is convenient in combination with -h, -l, and -R. -R Print only the name of the RCS file. This is convenient for translating a working pathname into an RCS pathname. -h Print only the RCS pathname, working pathname, head, default branch, access list, locks, symbolic names, and suffix. -t Print the same as -h, plus the descriptive text. -N Do not print the symbolic names. -b Print information about the revisions on the default branch, normally the highest branch on the trunk. -ddates Print information about revisions with a checkin date/time in the ranges given by the semicolon-separated list of dates. A range of the form d1<d2 or d2>d1 selects the revisions that were deposited between d1 and d2 exclusive. A range of the form <d or d> selects all revisions earlier than d. A range of the form d< or >d selects all revisions dated later than d. If < or > is followed by = then the ranges are inclusive, not exclusive. A range of the form d selects the single, latest revision dated d or earlier. The date/time strings d, d1, and d2 are in the free format explained in co(1). Quoting is normally necessary, especially for < and >. Note that the separator is a semicolon. -l[lockers] Print information about locked revisions only. In addition, if the comma-separated list lockers of login names is given, ignore all locks other than those held by the lockers. For example, rlog -L -R -lwft RCS/* prints the name of RCS files locked by the user wft. -r[revisions] prints information about revisions given in the comma-separated list revisions of revisions and ranges. A range rev1:rev2 means revi- sions rev1 to rev2 on the same branch, :rev means revisions from the beginning of the branch up to and including rev, and rev: means revisions starting with rev to the end of the branch containing rev. An argument that is a branch means all revisions on that branch. A range of branches means all revisions on the branches in that range. A branch followed by a . means the latest revision in that branch. A bare -r with no revisions means the latest revision on the default branch, normally the trunk. -sstates prints information about revisions whose state attributes match one of the states given in the comma-separated list states. -w[logins] prints information about revisions checked in by users with login names appearing in the comma-separated list logins. If logins is omitted, the user's login is assumed. -T This option has no effect; it is present for compatibility with other RCS commands. -V Print RCS's version number. -Vn Emulate RCS version n when generating logs. See co(1) for more. -xsuffixes Use suffixes to characterize RCS files. See ci(1) for details. rlog prints the intersection of the revisions selected with the options -d, -l, -s, and -w, intersected with the union of the revisions selected by -b and -r. -zzone specifies the date output format, and specifies the default time zone for date in the -ddates option. The zone should be empty, a numeric UTC offset, or the special string LT for local time. The default is an empty zone, which uses the traditional RCS format of UTC without any time zone indication and with slashes separating the parts of the date; otherwise, times are output in ISO 8601 for- mat with time zone indication. For example, if local time is January 11, 1990, 8pm Pacific Standard Time, eight hours west of UTC, then the time is output as follows: option time output -z 1990/01/12 04:00:00 (default) -zLT 1990-01-11 20:00:00-08 -z+05:30 1990-01-12 09:30:00+05:30 EXAMPLES
rlog -L -R RCS/* rlog -L -h RCS/* rlog -L -l RCS/* rlog RCS/* The first command prints the names of all RCS files in the subdirectory RCS that have locks. The second command prints the headers of those files, and the third prints the headers plus the log messages of the locked revisions. The last command prints complete information. ENVIRONMENT
RCSINIT options prepended to the argument list, separated by spaces. See ci(1) for details. DIAGNOSTICS
The exit status is zero if and only if all operations were successful. IDENTIFICATION
Author: Walter F. Tichy. Manual Page Revision: 5.9; Release Date: 1995/06/16. Copyright (C) 1982, 1988, 1989 Walter F. Tichy. Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert. SEE ALSO
ci(1), co(1), ident(1), rcs(1), rcsdiff(1), rcsintro(1), rcsmerge(1), rcsfile(5) Walter F. Tichy, RCS--A System for Version Control, Software--Practice & Experience 15, 7 (July 1985), 637-654. BUGS
The separator for revision ranges in the -r option used to be - instead of :, but this leads to confusion when symbolic names contain -. For backwards compatibility rlog -r still supports the old - separator, but it warns about this obsolete use. GNU
1995/06/16 RLOG(1)
All times are GMT -4. The time now is 09:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy