Hi All
I have a requirement like below.I have always 12 files got generated in my directory called /xx/out/
Out of these files I have to select the files based on the below condition and delete the rest of the files.
if it is a JAN month then fetch ----- Jan to Dec = 12 files
if it is a FEB month then fetch ----- Jan + Oct + Nov + Dec = 4 files
if it is a MAR month then fetch ----- Jan + Feb + Oct + Nov + Dec = 5 files
if it is a APR month then fetch ----- Jan + Feb + Mar + Oct + Nov + Dec = 6 files
if it is a MAY month then fetch ----- Apr + Jan + Feb + Mar = 4 files
if it is a JUN month then fetch ----- Apr + May + Jan + Feb + Mar = 5 files
if it is a JUL month then fetch ----- Apr + May + Jun + Jan + Feb + Mar = 6 files
if it is a AUG month then fetch ----- Jul + Apr + May + Jun = 4 files
if it is a SEP month then fetch ----- Jul + Aug + Apr + May + Jun = 5 files
if it is a OCT month then fetch ----- Jul + Aug + Sep + Apr + May + Jun = 6 files
if it is a NOV month then fetch ----- Oct + Jul + Aug + Sep = 4 files
if it is a DEC month then fetch ----- Oct + Nov + Jul + Aug + Sep = 5 files
can any one tell how to achieve this
Regards
Sri
Last edited by Franklin52; 11-13-2014 at 07:37 AM..
Reason: Please use code tags
I have tried it by extracting the date and doing it by -1,-2.. inside a CASE .
Any better ideas other than this.
Regards
Sri
---------- Post updated at 11:51 PM ---------- Previous update was at 11:47 PM ----------
Hi Ongoto
This is not the homework. For some of the attributes in the files ,updation happens in the later months.That is the reason extracting the previous months files along with the current month.
Regards
Sri
Your conditions are kinda complicated because they change each month and cycle back every 3 months, so you would need to set different file age limits for each month.
Whadda think about testing each filename in a loop ?
Maybe something like this.
I am not able to fetch first date and last date previous month
date -d -1month +%Y-%m-%d
date -d -1month +%Y-%m-%d
I need two format dd-mm-yyy
previous month 01-03-2016
previous month 31-03-2016
and also only date 1 to 31
Aprriciate your replay (4 Replies)
Hi,
Please help to fetch the values for a key from below data format in linux.
Sample Input Data Format
11055005|PurchaseCondition|GiftQuantity|1
11055005|PurchaseCondition|MinimumPurchase|400
11055005|GiftCatalogEntryIdentifier|Id|207328014
11429510|PurchaseCondition|GiftQuantity|1... (2 Replies)
Hi ,
I need a script which moves files based on month. Example :
Apr 29 03:16 log4.txt
Apr 29 03:16 log5.txt
May 4 09:17 log1.txt
May 4 09:17 log2.txt
Move Apr files into Apr2015(Folder)
Move May files into May2015(Folder).
This is urgent requirement , if you can help me... (5 Replies)
Hi All,
I am trying to achieve the below logic, could you please help me in this.
In second row 2nd column I've Value JC2 and the same JC2 is 4th row 1st column.So I need to replace JC2 value in 4th row with JC2 2nd row's 1st column.
Input:
Job1,JC1
Job1,JC2
Job1,JC3
JC2,JA1... (6 Replies)
Hi,
I need all file names in a folder which has date >= 10th of last month,
Example
: files in folder
AUTO_F1_20140610.TXT
BUTO_F1_20140616.TXT
CUTO_F1_20140603.TXT
FA_AUTO_06012014.TXT
LA_AUTO_06112014.TXT
MA_AUTO_06212014.TXT
ZA_AUTO_06232014.TXT
Output:
AUTO_F1_20140610.TXT... (9 Replies)
Hi All,
I want to move the files in to different folders based on the files month in the file timestamp.
For example
All the september files in the directory should moves into the folder "sep_bkp_files" , August files in to aug_bkp_files folder...
Please help me to achive the above... (10 Replies)
I have a requirement where in i need to select records right below the search criteria
qwertykeyboard white
10 20 30
30 40 50
60 70 80
qwertykeyboard black
40 50 60
70 90 100
qwertykeyboard and white are headers separated by a tab.
when i execute my script..i would be searching... (4 Replies)
Hello,
I'm trying to move the log files from the parent directory to respective monthly folder and I would be running this script on a weekly basis through cron.
I'm new to this scripting and here is what i could come up and it runs without really doing anything. I even tried placing echo... (2 Replies)
I have files like
pra.01
sra.02
see.03
swc.03
sre.04
after dot it contain month format when ever user type "01" month i have to fetch what are 01 files to come (2 Replies)
I have a file which will have rows like shown below,
ST*820*316054716
RMR*IV*11333331009*PO*40.31
REF*IV*22234441009*xsss471-2762
DTM*003*091016
ENT*000006
RMR*IV*2222234444*PO*239.91
REF*IV*1234445451009*LJhjlkhkj471-2762 </SPAN>
DTM*003*
091016
RMR*IV*2223344441009*PO*40.31... (18 Replies)