Get the sorted list of visible files and go through them one at a time in order as file,
Strip off the date portion at the end, with underscore, as file_base,
If the stored last file base is the same (blank first time never equal), then the last file is younger. Actually, it's be nicer if the suffix was YYYY-MM-DD, as this fails at new year.
Try again:
Go to the current dir so file names have no dir prefix,
list just the well named files to pipe,
prefix them with the key field YYMMDD on pipe, sticking the base in the stream using sed for simplicity,
sort them by date and then prefix pipe to pipe,
'while read' puts the three fields into three variables for each line from stdin pipe until EOF.
If same base as last file, last file must be moved.
If file is moved, in a subshell that captures stdout as a string $(...), list the archive dir for that base and date wild card suffix and count the lines of the list,
(( )) is ksh arithmetic mode, so you can say 6 < for testing the line count, # I put 6 first, > 6, as 6 is smaller tha $(...), gets lost at end.
while 6 is less than that line count,
list by file mod time oldest first (is mod time a safe test, or do we need a key rearrange and sort like above?),
read the first name,
remove that name,
end while 6 loop with done,
end if bases are same test with fi,
save file name and prefix in last_* variables for next pass,
end while read file loop with done
Last edited by DGPickett; 08-03-2011 at 02:34 PM..
I am trying to write a shell script that will remove files in a directory based on the date. For instance, remove all files older than yesterday. Any ideas? (4 Replies)
Hi Friends,
Can anyone help me with this:
To get the count of files that are existing in a directory created on a perticular date like in the example (01/08) .(having same pattern for the filename)
ex:
FileName Creted Date
FILE001 01/08/2007
FILE005 ... (6 Replies)
Hello friends,
I'm learning to script, and I need help.
How can I get the latest/newest files based on date? the format is as following:
Feb 07 19:25 TESTPWD_file_1vk6pn40_19519_1
Feb 07 19:46 TESTPWD_file_1uk6pn40_19518_2
Feb 07 19:47 TESTPWD_file_20k6pn40_19520_2
Feb 07 19:56... (5 Replies)
hi all,
here is the description to my problem.
input parameters: $date1 & $date2
based on the range i need to select the archived files from the archived directory and moved them in to working directory.
can u please help me in writing the code to select the multiple files based on the... (3 Replies)
Hi all
i am having so many files in my directory.Is there any option
to copy files based on date.
example
i am having file this
-rw-rw-r-- 1 ram user 1 Feb 2 17:12 abc
-rw-rw-r-- 1 ram user 1 Feb 2 17:12 bnw
-rwxrwxr-x 1 ram user 21122 Feb 4... (3 Replies)
Hello team,
I have a number of files in a folder which are dated yesterday and today.Can i remove all the files which i created today based on date??
is there any syntax for this ?? (1 Reply)
We have year folder say in a path /opt/informat/Archive a folder 2012.
And in the same folder /opt/informat/Archive we have different folders month based, like 201210, 201211, 201212, this have data for each month, ie files. Now time to time i need to move the monthly folders to the main folder... (1 Reply)
Hi All,
I do have an EBCDIC file sent from the z/os , this file has records with different record types in it, the type of record is identified by bytes 45-46 like
value 12 has employee record
value 14 has salaray record and etc....
we do now want to split the big ebcdic file into multiple... (3 Replies)
My unix version is IBM AIX Version 6.1
I tried google my requirement and found the below answer,
find . -newermt “2012-06-15 08:13" ! -newermt “2012-06-15 18:20"
But newer command is not working in AIX version 6.1 unix
I have given my requirement below:
Input:
atr files:
... (1 Reply)
I am trying to work on a script where it is a *(star) delimited file has a multiple lines starts with RTG and 3rd column=TD8 I want to substring the date part and
I want to replace with currentdate minus 15 days. Here is an example. iam using AIX server
$ cat temp.txt
RTG*888*TD8*20180201~... (1 Reply)