Sponsored Content
Top Forums Shell Programming and Scripting List the file or files with last modification date Post 302360917 by KitFisto on Sunday 11th of October 2009 12:00:52 PM
Old 10-11-2009
List the file or files with last modification date

hi. I need help my programing friends Smilie

I need to list all the files with a certain name (for example FileName) by last modification date but only the one with the last date. If there are two files with the same name and same modification date it should print the both.
For example in this set of files:

-rw-r--r-- 13 09/23/09 15:52:38 ./aa/FileName
-rw-r--r-- 16 09/23/09 15:52:38 ./cc/cc/FileName
-rw-r--r-- 16 09/23/09 15:54:34 ./cc/FileName
-rw-r--r-- 13 09/23/09 15:54:03 ./aa/dd/FileName
-rw-r--r-- 6 09/23/09 15:54:23 ./bb/FileName

it should return:

-rw-r--r-- 13 09/23/09 15:52:38 ./aa/FileName
-rw-r--r-- 16 09/23/09 15:52:38 ./cc/cc/FileName

because they have the same name and modification date.

I have this command but it list all files it finds:

ls -tl $(find . -name FileName)

Could someone help me?
Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

command for modification date of a file

Good morning, I would like to find all files of a certain type and display their name as well as their modification date. In order to do this, I would do the following: find ./ -name *.csv | ???????? My question: what to put after the pipe instead of the question marks? Is there a basic... (5 Replies)
Discussion started by: scampsd
5 Replies

2. Shell Programming and Scripting

Copy files based on modification date

How to copy files from a location to a directory <YYMM> based on last modification date? This will need to run daily. I want to copy those file for May to 0905 and Jun to 0906. Appreciate your guidance.:) Thanks. -rw-rw-rw- 1 ttusr tgrp 4514 May 29 21:49 AB24279J.lot_a... (17 Replies)
Discussion started by: KhawHL
17 Replies

3. UNIX for Advanced & Expert Users

Help with sorting files according to modification date

Hi, I was very surprised to not be able to find an answer to this question despite my best efforts in Google and elsewhere. Maybe it's a good thing as it forced me to finally become a member in this great forum that i use frequently. Ok my question: I want to be able to sort files inside a... (3 Replies)
Discussion started by: stavros
3 Replies

4. Shell Programming and Scripting

Rename old files with last modification date

Hi everyone, I have files like file1_Mod.txt, file2_Mod.txt. I want to rename the old files with the last modification date. I write the below script to rename with current date, but I donīt know how to use "date -r" to get the last modification date with the same format I have below... (5 Replies)
Discussion started by: cgkmal
5 Replies

5. Shell Programming and Scripting

How to list the files based on the modification time using the find command?

Hi All, I need to list the files based modification time of the files from a directory, I cannot use "ls -t" as there are lot of files, which "ls" command cannot handle. New files will land there daily. So iam looking for an alternative through "find"command. All suggestions are welcomed. ... (6 Replies)
Discussion started by: Kesavan
6 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

How do you get the last modification date of a file?

I'm trying to get the date output to be in the form yyyy-mm-dd (e.g. 2013-01-18) !/bin/sh modDate=$(stat -c %y $1) echo $modDate >> $1 When I run this on another file (by typing ./dateScript theFile.txt), I keep getting this message: stat: illegal option -- c What's wrong with my code... (2 Replies)
Discussion started by: Nate18
2 Replies

8. Shell Programming and Scripting

How to list files that are not first two files date & last file date for every month-year?

Hi All, I need to find all files other than first two files dates & last file date for month and month/year wise list. lets say there are following files in directory Mar 19 2012 c.txt Mar 19 2012 cc.txt Mar 21 2012 d.txt Mar 22 2012 f.txt Mar 24 2012 h.txt Mar 25 2012 w.txt Feb 12... (2 Replies)
Discussion started by: Makarand Dodmis
2 Replies

9. Shell Programming and Scripting

Sort and move multiple files by modification date

Hi I have a problem, I have a large group of archive files in a folder some are later versions of the same archive, the only difference btween them is that the archiving program we use appends the name with a code for it to keep track of in its data base, and the modification date. I am starting... (6 Replies)
Discussion started by: Paul Walker
6 Replies

10. Shell Programming and Scripting

Subtract a file's modification date with current date

SunOS -s 5.10 Generic_147440-04 sun4u sparc SUNW,SPARC-Enterprise Hi, In a folder, there are files. I have a script which reads the current date and subtract the modification date of each file. How do I achieve this? Regards, Joe (2 Replies)
Discussion started by: roshanbi
2 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 10:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy