Thanks in advance
tail -2 return two file but I have to handle the film type there is two type in example STATE AND MEdd I want that code return one from state type and another from medd type on the basis of latest timestamp
Use ls' option -t to sort according to the files' time stamps. Assuming the file names' second and third last part being their modification time,
would yield the desired.
I want to fetch the latest file form the list
example
example= filename RATE_STATE_SETUPS.20151222.ccyymmdd.hhmmss.txt
File pick which have latest ccyymmdd.hhmmss
list of file in directory are
I want that code return two latest file
My code return only one file
My OS is AIX 6
Thanks in advance
Moderator's Comments:
As requested several times before, please use CODE tags for sample input, sample output, and code; not just for code.
Your script does not produce that output; it would only print:
And that would be from performing an alphanumeric sort on the strings:
not from a numeric sort on:
I would guess that you wanted to include the date as well as the time in the sort anyway, so you may have accidentally gotten the date and timestamp you wanted.
If you need to sort on the date specified by the file names instead of by the files' timestamps, you might want something more like:
If it is something you'll be doing frequently, you could replace two invocations of head, one invocation of ls, and two invocations of sort with one invocation of awk with something like:
which, with your sample filenames, would produce the output:
but the order in which these two lines will be printed is unspecified.
Last edited by Don Cragun; 01-28-2016 at 03:35 PM..
Reason: Fix typo: s/alphanumeric/alphanumeric sort/
Hi,
I have a file where versions will be updated, i need to get latest/last updated version from that file. Could you please help?
File looks like below -
<versions>
<version>R20180417.006</version>
<version>R20180421.007</version>
<version>R20180421.008</version>
... (5 Replies)
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... (1 Reply)
I need to write a shell script to display the output of ls command like this
ls -ltr *txt
I get this
-rw-r----- 1 oracle dba 51912704 Dec 11 10:27 /usr/local/sam/test12112012101247AM.txt
-rw-r--r-- 1 oracle dba 7 Dec 11 11:58 /usr/local/sam/test.txt
but I just need the latest... (7 Replies)
Hi,
How to fetch data from oracle database in unix shell scripting.
list=`sqlplus -s ds_user/dsuser@EMI <<EOF
set feedback off
set serveroutput on
set heading off
set pagesize 0
set tab off
select IP_ID from table
/
exit
EOF`
The output is not what i expected.I need output in... (4 Replies)
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)
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)
Hi All,
Requirement is to fetch hostname and instance name using shell script from all configuration files on a server R12 on IBM AIX...
could anyone please share such an experience encountered before.Is there such a script available in this forum or any other site..
Thanks for your time!... (0 Replies)
Hello All,
Hope u r doing fine.
I'm writing a shell script to ftp the latest file having pericular convention as 'ULTI_15072007043205.txt' on daily basis.
Now the date & timing of the file geleration isnt constant, so the file name daily varies as per the date & timing of generation.
Can anyone... (7 Replies)