12-13-2012
Help with finding the latest modified version of a file within directories
I am trying to look into multiple directories and pluck out the latest version of a specific file, regardless of where it sits within the directory structure.
Ex:
The file is a .xls file and could have a depth within the directory of anywhere from 1-5
Working directory - Folder1
Similar .xls files may be in Folder1/x1/x2/x3 and also Folder1/y1/y2, but I want to output only the latest modified .xls file to pipe into a cp command for use in a shell script.
I am using csh (I know, I know!) and any help in doing this would be appreciated.
I've tried using forms of find.-type f -name "*.xls" , but am not sure how to only take the latest from that listing of all the .xls files within the directory tree.
Thanks!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
:o How do I confirm that the script on one server is latest compare to other servers? Is there any script which can tell me the latest version of a file across the servers?
Thanks, (2 Replies)
Discussion started by: Sandy
2 Replies
2. Shell Programming and Scripting
Hi,
Is there any simple way to get the last modified file in a set of 2 or more directories? This should return one file only (not 1 file per directory)
Thanks for your help (4 Replies)
Discussion started by: m69w
4 Replies
3. Shell Programming and Scripting
hi,
I want to find a file which is modified within last 2 hours
i am using sun-os
i tried find . -name <filename> -mmin 120
i found that mmin option is not supported in sun-os is there any other alternative option
suggestions welcome
thanks in advance (5 Replies)
Discussion started by: trichyselva
5 Replies
4. Shell Programming and Scripting
hi Friends,
In my directory i have some files. I need to find out latest modified file. Please help me.
Sreenu. (2 Replies)
Discussion started by: sreenu80
2 Replies
5. UNIX for Dummies Questions & Answers
I only know how to list all sub-directories or files in specified directory. I don't know how to order them by modified date, furthermore, I don't know how to get the top one file in the sorted list. Wish you can do me a favor. Thanks in advance! (3 Replies)
Discussion started by: crest.boy
3 Replies
6. Shell Programming and Scripting
Dear all,
Need a quick help/suggestion on monitoring a particular directory .
We have a deployment directory say (/users/integration/deploy ) under this there are several files which can be edited by a number of users -
We need to write a script which will check this deployment directory... (5 Replies)
Discussion started by: jambesh
5 Replies
7. UNIX for Advanced & Expert Users
Hi,
I am new bie to Unix. Might be a simple question I am asking.
I want to find the last modified time of a file and find the difference between the currrent time and the last modified time. Appreciate, if someone can throw some light on what commands can be used.
Cheers,
James (2 Replies)
Discussion started by: JamesJoe
2 Replies
8. Shell Programming and Scripting
Hi Everyone,
I am writing a shell script and I am struck here:
I need to find the latest file in a directory depending upon the date.
For example:
The files in the directory are:
Filename_bo_20110619
Filename_bo_20110620
Filename_bo_20110621
Filename_bo_20110622
So here, I want... (2 Replies)
Discussion started by: filter
2 Replies
9. Shell Programming and Scripting
I wan to pick the latest modified file name and redirect it to a file ..
ls -tr | tail -1 >file
but this is printing file ins side the filename ,
can anyone help me out (5 Replies)
Discussion started by: vishwakar
5 Replies
10. UNIX for Dummies Questions & Answers
I am trying to fetch the latest modified file from a directory using the command
find . -type f -exec ls -lt \{\} \+ | head | awk '{print $9}'
After the O/P, I get the below mentioned error and the command doesnt terminate at all.
find: ls terminated by signal 13
find: ls terminated by... (2 Replies)
Discussion started by: Sree10
2 Replies
LEARN ABOUT DEBIAN
dbd::excel
Excel(3pm) User Contributed Perl Documentation Excel(3pm)
NAME
DBD::Excel - A class for DBI drivers that act on Excel File.
This is still alpha version.
SYNOPSIS
use DBI;
$hDb = DBI->connect("DBI:Excel:file=test.xls")
or die "Cannot connect: " . $DBI::errstr;
$hSt = $hDb->prepare("CREATE TABLE a (id INTEGER, name CHAR(10))")
or die "Cannot prepare: " . $hDb->errstr();
$hSt->execute() or die "Cannot execute: " . $hSt->errstr();
$hSt->finish();
$hDb->disconnect();
DESCRIPTION
This is still alpha version.
The DBD::Excel module is a DBI driver. The module is based on these modules:
* Spreadsheet::ParseExcel
reads Excel files.
* Spreadsheet::WriteExcel
writes Excel files.
* SQL::Statement
a simple SQL engine.
* DBI
Of course. :-)
This module assumes TABLE = Worksheet. The contents of first row of each worksheet as column name.
Adding that, this module accept temporary table definition at "connect" method with "xl_vtbl".
ex.
my $hDb = DBI->connect(
"DBI:Excel:file=dbdtest.xls", undef, undef,
{xl_vtbl =>
{TESTV =>
{
sheetName => 'TEST_V',
ttlRow => 5,
startCol => 1,
colCnt => 4,
datRow => 6,
datLmt => 4,
}
}
});
For more information please refer sample/tex.pl included in this distribution.
Metadata
The following attributes are handled by DBI itself and not by DBD::Excel, thus they all work like expected:
Active
ActiveKids
CachedKids
CompatMode (Not used)
InactiveDestroy
Kids
PrintError
RaiseError
Warn (Not used)
The following DBI attributes are handled by DBD::Excel:
AutoCommit
Always on
ChopBlanks
Works
NUM_OF_FIELDS
Valid after "$hSt->execute"
NUM_OF_PARAMS
Valid after "$hSt->prepare"
NAME
Valid after "$hSt->execute"; undef for Non-Select statements.
NULLABLE
Not really working, always returns an array ref of one's. Valid after "$hSt->execute"; undef for Non-Select statements.
These attributes and methods are not supported:
bind_param_inout
CursorName
LongReadLen
LongTruncOk
Additional to the DBI attributes, you can use the following dbh attribute:
xl_fmt
This attribute is used for setting the formatter class for parsing.
xl_dir
This attribute is used only with "data_sources" on setting the directory where Excel files ('*.xls') are searched. It defaults to the
current directory (".").
xl_vtbl
assumes specified area as a table. See sample/tex.pl.
xl_skiphidden
skip hidden rows(=row height is 0) and hidden columns(=column width is 0). See sample/thidden.pl.
xl_ignorecase
set casesensitive or not about table name and columns. Default is sensitive (maybe as SQL::Statement). See sample/thidden.pl.
Driver private methods
data_sources
The "data_sources" method returns a list of '*.xls' files of the current directory in the form "DBI:Excel:xl_dir=$dirname".
If you want to read the subdirectories of another directory, use
my($hDr) = DBI->install_driver("Excel");
my(@list) = $hDr->data_sources(
{ xl_dir => '/usr/local/xl_data' } );
list_tables
This method returns a list of sheet names contained in the $hDb->{file}. Example:
my $hDb = DBI->connect("DBI:Excel:file=test.xls");
my @list = $hDb->func('list_tables');
TODO
More tests
First of all...
Type and Format
The current version not support date/time and text formating.
Joins
The current version of the module works with single table SELECT's only, although the basic design of the SQL::Statement module allows
joins and the likes.
KNOWN BUGS
o There are too many TODO things. So I can't determind what is BUG. :-)
AUTHOR
Kawai Takanori (Hippo2000) kwitknr@cpan.org
Homepage:
http://member.nifty.ne.jp/hippo2000/ (Japanese)
http://member.nifty.ne.jp/hippo2000/index_e.htm (English)
Wiki:
http://www.hippo2000.net/cgi-bin/KbWiki/KbWiki.pl (Japanese)
http://www.hippo2000.net/cgi-bin/KbWikiE/KbWiki.pl (English)
SEE ALSO
DBI, Spreadsheet::WriteExcel, Spreadsheet::ParseExcel, SQL::Statement
COPYRIGHT
Copyright (c) 2001 KAWAI,Takanori All rights reserved.
You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
perl v5.8.8 2008-03-01 Excel(3pm)