09-18-2013
Find the latest file based on the date in the filename
Hi,
We've a list of files that gets created on a weekly basis and it has got a date and time embedded to it. Below are the examples. I want to find out how to get the latest files get the date and time stamp out of it.
Files are
PQR123.PLL.M989898.201308012254.gpg
PQR123.PLL.M989898.201308081254.gpg
PQR123.PLL.M989898.201308151554.gpg
PQR123.PLL.M989898.201308221454.gpg
PQR123.PLL.M989898.201308291354.gpg
So from the above files PQR123.PLL.M989898.201308291354.gpg is latest file since it was sent on August 29 at 1:54 pm. I need to get the date and timestamp of it which is "201308291354". Naming convention of the file always remains the same except 4th field is DATE AND TIME.
Need to use an awk command to get it.
Thanks,
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
:confused: There is a flat file on my system which contains email addreses of people in my company. This file is utilized when sending notifications for various things. However nobody knows where this file is located or what it is named. The only thing we know is the email address of a user who... (4 Replies)
Discussion started by: kollerj
4 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I grep for a pattern in a list of files.
"grep -i -l $pattern *.datx*"
it may give me n number of files.
say for eg, it gives me 2 files.
lock_eicu_20071228_00000000.dat_20071228_05343100
lock_eicu_20080501_00000000.dat_20080501_05343900
out of these 2 files I need to get the... (7 Replies)
Discussion started by: prsshini
7 Replies
3. Shell Programming and Scripting
hi all,
not sure if this has been posted b4 but i try to search but not valid.
this is my question:
when i do a ls -ltr there will be a list generated as follows:
-rw-r--r-- 1 root sys 923260 Jan 10 04:38 FilePolling.41025.083TL021.xml
-rw-r--r-- 1 root sys 1761337 Jan 10 04:40... (12 Replies)
Discussion started by: lweegp
12 Replies
4. Shell Programming and Scripting
How to FTP the latest file, based on date, from a remote server through a shell script?
I have four files to be FTP'ed from remote server.
They are of the following format.
build1_runtime_mmddyyyy.txt
build2_runtime_mmddyyyy.txt
build3_runtime_mmddyyyy.txt
buifile_count_mmddyyyy.txt
... (9 Replies)
Discussion started by: imran_affu
9 Replies
5. Shell Programming and Scripting
I am using ksh93 on Solaris.
Ok, this may seem like a simple request at first. I have a directory that contains sets of files with a YYYYMMDD component to the name, along with other files of different filespecs. something like this:
20110501_1.dat
20110501_2.dat
20110501_3.dat... (2 Replies)
Discussion started by: gary_w
2 Replies
6. Shell Programming and Scripting
I'm having problems with my bash script. I would like to find a file matching today's date in the filename, i.e. my_file_20120902.txt and then move it to a different directory, i.e. /tmp. Thanks. (1 Reply)
Discussion started by: jamesi
1 Replies
7. Shell Programming and Scripting
hi i need the shell script to get the file with latest date.
for example in my input folder i have files like
file_20130212.txt
file_20130211.txt
now my output folder should have the file with latest date i.e..file_20120212.txt
i want to get the latest file .. i.e is should take... (6 Replies)
Discussion started by: hemanthsaikumar
6 Replies
8. Shell Programming and Scripting
HI
I have folder in home dir.
/home/kpp/07222013
/home/kpp/07212013
/home/kpp/07202013
Output :--
/home/kpp/07222013
Just find latest date (5 Replies)
Discussion started by: pareshkp
5 Replies
9. UNIX for Dummies Questions & Answers
Hi all,
I am a newbie here. I have this requirement to find a file based on a pattern then return the filename if found.
I created a script based on online tutorials. Though, I am stuck & really appreciate if anyone can have a quick look & point me to the right direction?
#Script starts... (10 Replies)
Discussion started by: buster_t
10 Replies
10. Shell Programming and Scripting
Hi,
I have a directory that has numerous files in it, and there is two which are named "filerec_ddmmyyHH24MMSS" by the time they are created so "filerec_010615012250" was created at 01:22:50 on 1st June 2015.
I need to find the most recently created of those 2 files and get the contents of... (4 Replies)
Discussion started by: finn
4 Replies
LEARN ABOUT DEBIAN
genplotfiles
GENPLOTFILES(1) colplot GENPLOTFILES(1)
NAME
genplotfiles - utility to help automate creation of collectl plot file from raw ones
SYNOPSIS
/opt/hp/colplot/genplotfiles.pl -outdir [-switches]
DESCRIPTIONS
This utility is not intended to meet all plot file creation needs, but quite frankly should meet most. Features not provided with this
utility are best realized by running collectl directly in playback mode (see collectl -p). It is therefore important to understand what
this utility will and will not do for you before building an automation strategy around it.
The algorithm used is fairly simple - genplotfiles examines each collectl raw file to see it it falls within the data ranges (if specified)
and contains a matching hostname (if specified). If a plot file already exists, the timestamps are compared and the raw file skipped if
its newer than the plotfile.
Any raw files that pass all these tests are then passed to collectl with their timestamp wildcarded. The result is all raw files for that
host/date will be processed. This means if you copy over collectl raw files multiple times over the course of the day using rsync, you can
immediately genererate up-to-date plots for them using genplotfiles. Furthermore, you won`t even need any date parameters if the older
plot files are alreay up to date.
For an example of what a cron job that aggregates multiple collectl logs onto a single system for plotting purposes, see crontab.sh in the
same directory as this script.
SWITCHES
All switches are optional with the exception of -outdir:
-colbin path-to-collectl
This points to collectl and is only necessary if /usr/sbin is not in your path or you`ve chosen to install collectl in a non-stan-
dard directory.
-debug number
Primarily for development, will provide intermediate processing information based on its value. See souce for details.
-force
Always generate plot files even in there is an existing one that is newer than the latest raw file. This will be necessary if you
want to rerun this script and just change the value of -subsys.
-help
Print a summary of available switches.
-host string
Only process files that contain this string in their hostname portion of the filename.
-indir directory
Directory where to look for collectl logs. The default is /var/log/collectl and is therefore only necessary if your logs are in a
non-standard location.
-outdir directory
Directory into which to write the plottable files. This field is required.
-fromdate date
Ignore files with a datestamp in their name less that this value. The default is 20050101 and so defaults to all files. The value
of `yesterday` is also recognized to simplify scripts that call this.
-thrudate date
Ignore files with a datestamp in their name with a datestamp greater than this value. The default is the current day and one can
also specify a value of `yesterday`.
-subsys string
Instead of using the default subsystems for which data was collected, generate output files based on this set. There are basically
two reasons for doing this. The first is that you may want to reduce the size of the plot files, though with compression there is
rarely much point in this. The second is if you`ve asked collectl to collect summary data but want to plot detail data.
See the colplot FAQ for more information.
AUTHOR
This program was written by Mark Seger (mjseger@gmail.com).
Copyright 2005 Hewlett-Packard Development Company, L.P.
SEE ALSO
LOCAL
OCTOBER 2005 GENPLOTFILES(1)