Date wise calculations?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Date wise calculations?
# 8  
Old 04-16-2016
For exactly your sample and request, this might do:
Code:
egrep "2015.(09|10)|POST" file
POST_DATE    CHECK_NUMBER    TYPE    LOGIN_NAME
2015.09.09    XXXXXXXXXX    mark XXXXXXXXXX
2015.09.09    XXXXXXXXXX    fsadf    XXXXXXXXXX
2015.10.05    XXXXXXXXXX    defaa    XXXXXXXXXX
2015.10.05    XXXXXXXXXX    dewe    XXXXXXXXXX
2015.10.06    XXXXXXXXXX    dqwe    XXXXXXXXXX
2015.09.14    XXXXXXXXXX    dt4e    XXXXXXXXXX
2015.10.26    XXXXXXXXXX    dpwp    XXXXXXXXXX
2015.10.19    XXXXXXXXXX    dfsef    XXXXXXXXXX

# 9  
Old 04-18-2016
hey don,

thanks for the solution, how does it interprets the POST_DATE column, can u plz guide me?

Hey Ravinder

Thanks for the help, but it is not working as expected.

---------- Post updated at 11:35 AM ---------- Previous update was at 11:15 AM ----------

Rudi,

It is not working, It is even filtering the 11 and 12 month rows as well.

For 09 & 10 it works as expected, but as i change the parameter to 11 & 12 it does not

Code:
Code:
egrep -w "2015.(11|12)|POST" EXTRACT.txt | awk -F "|" '{print $12}' | head
2015.09.09
2015.11.02
2015.10.05
2015.10.05
2015.10.06
2015.09.14
2015.10.26
2015.10.19
2015.11.18
2015.09.15


rudi,

On further analysis i found out that it is actually grepping some 03 available in that particular line, I wanted only those available in POST_DATE Column.
the month wise calculations, i'll be doing it there.

Last edited by nikhil jain; 04-18-2016 at 03:28 AM..
# 10  
Old 04-18-2016
Some creativity with the regex might yield the correct result for column 1:
Code:
egrep "^2015.(11|12)|POST"  file

# 11  
Old 04-18-2016
my POST_DATE is not the column 1, It is column 12, Even this is not helping.
Code:
Code:
egrep "^2015.(03|04)|POST" EXTRACT.txt | head | awk -F "|" '{print $12}'
POST_DATE
POST_DATE
2015.12.02
 
2015.12.10
2015.12.28
2015.12.03
2015.12.21
2015.12.09

# 12  
Old 04-18-2016
Where did you specify that we're dealing with field 12?
# 13  
Old 04-18-2016
sorry my bad :-( I forgot to.
# 14  
Old 04-18-2016
PLEASE consider giving a clear, crisp, and detailed specification in the very first post!
Try
Code:
egrep "^([^ ]+ +){11}2015.(11|12)|POST"  file


Last edited by RudiC; 04-18-2016 at 04:03 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert values into a file 0 as per the date wise

Hi The file contains 12 months of date and less than 12 months of data I want to display if date filed less than 12 months of data I want to insert a value amount 1 to amount4 0 and dates as well. 12345|Date|cntry|amount1|amount2|amount3|amoun4... (2 Replies)
Discussion started by: jagu
2 Replies

2. Shell Programming and Scripting

Extract count of string in all files and display on date wise

Hi All, hope you all are doing well! I kindly ask you for shell scripting help, here is the description: I have huge number of files shown below on date wise, which contains different strings(numbers you can say) including 505001 and 602001. ... (14 Replies)
Discussion started by: VasuKukkapalli
14 Replies

3. Shell Programming and Scripting

Generate sum of a particular column date wise

Hi All, I have a file with below content 01/22/2014,23:43:00,1742.8, 01/22/2014,23:43:00,1742.8, 01/22/2014,23:44:00,1749.06666666667, 01/25/2014,23:45:00,2046.45, 01/25/2014,23:43:00,1742.8, 01/25/2014,23:44:00,1749.06666666667, 01/25/2014,23:45:00,2046.45, 01/25/2014,23:43:00,1742.8,... (4 Replies)
Discussion started by: villain41
4 Replies

4. Shell Programming and Scripting

How to read files by Server Creation date wise?

Hi All, I would have many files in the server with xyz*.dat -- Static file name Physical files: xyz1.dat - 01PM xyz2.dat - 02PM xyz3.dat - 03PM In present version we are using for f in $file_name do fname=`ls $f | grep -v ^'\|'$ | sed s/' '/'\\ '/g` .... sqlldr... (4 Replies)
Discussion started by: Dharv
4 Replies

5. Shell Programming and Scripting

Date Calculations using script!!

Hi all, Thanks in Advance , i am very new to programming part in script i think using some caluations+ sed command only we can do this process in script. for exampl: i have file in that one line is like this using sed i can replace the date and all but my requirement is The... (3 Replies)
Discussion started by: anishkumarv
3 Replies

6. Solaris

delete files by date wise

Hi guys, I want to delete files from june 13 to june 30, using rm command can any one tell me the sintax to remove. I ahve hunderd of core files in my /var dir. so i want to clear last month core files. Thanks in Advance.:)) (2 Replies)
Discussion started by: kurva
2 Replies

7. Shell Programming and Scripting

Need to zip the files date wise --urgent Help needed

Hi all, this is my first post, i need to write a script to zip the files with datewise below are the log files. -rw------- 1 root sso 85316156 May 24 22:11 core_test_smservaz_104_104_1243217459_8896 -rw------- 1 root sso 90413304 May 25 22:12 core_test_smservaz_104_104_1243303895_20912... (4 Replies)
Discussion started by: lcschandu
4 Replies

8. Shell Programming and Scripting

Need help with Date calculations in ksh

Hi Gurus, I am writing a script where we enter two dates, one a FROM DATE and the other a TO DATE. I need to validate that difference between the two dates is always less than or equal to 60 days. I could not find any date utility in ksh that could help me with this. Finally, I am deciding... (5 Replies)
Discussion started by: jidsh
5 Replies

9. UNIX for Dummies Questions & Answers

Date Calculations

I need to be able to use the current date and calculate 7 days ago to be stored in another variable to be passed to a file in my Unix shell script. I need the date in the following format: date '+%m/%d/%Y' or 05/16/2006 How do I calculate date minus 7 days or 1 week ago? (8 Replies)
Discussion started by: mitschcg
8 Replies

10. Shell Programming and Scripting

To extract data of a perticular interval (date-time wise)

I want a shell script which extract data from a log file which contains date and time-wise data and i need the data for a perticular interval of time...what can i do??? (3 Replies)
Discussion started by: abhishek27
3 Replies
Login or Register to Ask a Question