Help in writing the scirpt for grepping on patterns in the directories created previous day


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help in writing the scirpt for grepping on patterns in the directories created previous day
# 1  
Old 12-13-2011
Help in writing the scirpt for grepping on patterns in the directories created previous day

Hi,
I have a challenging requiremant to be done in one daySmilie

there is directory in which a new directory gets created per hour i.e 24 directories per a day like below.

Code:
Dec 01 00:04 2011.12.12-23
Dec 01 01:11 2011.12.10-07
Dec 01 01:11 2011.12.10-08
Dec 01 01:11 2011.12.10-09
Dec 01 01:11 2011.12.10-10
Dec 01 01:11 2011.12.10-11
Dec 01 01:11 2011.12.10-12
Dec 01 01:11 2011.12.10-13
Dec 01 01:11 2011.12.10-14
Dec 01 01:11 2011.12.10-15
Dec 01 01:11 2011.12.10-16
Dec 01 01:11 2011.12.10-17
Dec 01 01:11 2011.12.10-18
Dec 01 01:11 2011.12.10-19
Dec 01 01:11 2011.12.10-20
Dec 01 01:11 2011.12.10-21
Dec 01 01:11 2011.12.10-22
Dec 01 01:11 2011.12.10-23
Dec 01 02:04 2011.12.13-01
Dec 01 03:05 2011.12.13-02
Dec 01 04:04 2011.12.13-03
Dec 01 05:04 2011.12.13-04
Dec 01 06:04 2011.12.13-05
Dec 01 07:03 2011.12.13-00
Dec 01 07:04 2011.12.12-00
Dec 01 07:04 2011.12.13-06

each of the above directory has one MERGED~000.NRAW.BOF file in it which has some info like below

Code:
bash-3.00$ cd 2011.12.13-06
bofDump MERGED~000.NRAW.BOF
 
bash-3.00$ bofDump MERGED~000.NRAW.BOF 
 
[268084],  152891347, 200659695,  [1323762316], 2011.12.13-07.45.16,  0.0d
[268085],  152891347, 200659696,  [1323759614], 2011.12.13-07.00.14,  0.0d
[268086],  152891347, 200659696,  [1323760514], 2011.12.13-07.15.14,  0.0d
[268087],  152891347, 200659696,  [1323761414], 2011.12.13-07.30.14,  0.0d
[268088],  152891347, 200659696,  [1323762316], 2011.12.13-07.45.16,  0.0d
[268089],  152891347, 200659700,  [1323759614], 2011.12.13-07.00.14,  0.0d
[268090],  152891347, 200659700,  [1323760514], 2011.12.13-07.15.14,  0.0d
[268091],  152891347, 200659700,  [1323761414], 2011.12.13-07.30.14,  0.0d
[268092],  152891347, 200659700,  [1323762316], 2011.12.13-07.45.16,  0.0d
[268093],  152891347, 200659704,  [1323759614], 2011.12.13-07.00.14,  0.0d
[268094],  152891347, 200659704,  [1323760514], 2011.12.13-07.15.14,  0.0d
[268095],  152891347, 200659704,  [1323761414], 2011.12.13-07.30.14,  0.0d
[268096],  152891347, 200659704,  [1323762316], 2011.12.13-07.45.16,  0.0d
[268097],  152891347, 200659706,  [1323759614], 2011.12.13-07.00.14,  0.0d
[268098],  152891347, 200659706,  [1323760514], 2011.12.13-07.15.14,  0.0d
[268099],  152891347, 200659706,  [1323761414], 2011.12.13-07.30.14,  0.0d
[268100],  152891347, 200659706,  [1323762316], 2011.12.13-07.45.16,  0.0d
[268101],  152891347, 200659711,  [1323759614], 2011.12.13-07.00.14,  0.0d
[268102],  152891347, 200659711,  [1323760514], 2011.12.13-07.15.14,  0.0d
[268103],  152891347, 200659711,  [1323761414], 2011.12.13-07.30.14,  0.0d
[268104],  152891347, 200659711,  [1323762316], 2011.12.13-07.45.16,  0.0d
[268105],  152891347, 200659712,  [1323759614], 2011.12.13-07.00.14,  0.0d
[268106],  152891347, 200659712,  [1323760514], 2011.12.13-07.15.14,  0.0d
[268107],  152891347, 200659712,  [1323761414], 2011.12.13-07.30.14,  0.0d
[268108],  152891347, 200659712,  [1323762316], 2011.12.13-07.45.16,  0.0d
[268109],  152891347, 200659716,  [1323759614], 2011.12.13-07.00.14,  0.0d
[268110],  152891347, 200659716,  [1323760514], 2011.12.13-07.15.14,  0.0d
[268111],  152891347, 200659716,  [1323761414], 2011.12.13-07.30.14,  0.0d
[268112],  152891347, 200659716,  [1323762316], 2011.12.13-07.45.16,  0.0d

bofDump is the command for opening the .BOF file.


Now i want to grep on patterns like 152891347, 152891354, 152894658 Etc. in all the .BOF files and in all 24 directories created yesterday and i want to take the extracted data in a text file. Can any one help me on this???
i tried hard but couldn't proceed furtherSmilie


Moderator's Comments:
Mod Comment Please use code tags!

Last edited by zaxxon; 12-13-2011 at 10:48 AM.. Reason: code tags, see PM
# 2  
Old 12-13-2011
bofDump -- Proviso concept .. Cool .. Smilie

Based on your input given .. Try the below ..
Code:
$ egrep "15289(1347|1354|4658)" 2011.12.12*/* > outfile.txt

# 3  
Old 12-13-2011
MySQL Help in writing the scirpt for grepping on patterns in the directories created previous day Reply to

Thanks buddy... thats really cool...but I made some changes in the command. Posting the same below
Code:
DATE_STAMP=`TZ=CST+24 date +%Y.%m.%d`
echo $DATE_STAMP
bofDump $DATE_STAMP*/*.BOF | egrep "10058(0981|0982|1038|1051|1055|1049)" > outfile.txt


Moderator's Comments:
Mod Comment Please use code tags!

Last edited by zaxxon; 12-13-2011 at 10:48 AM.. Reason: code tags, see PM
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get previous day from UNIX AIX?

Does anybody know how to get previous day on UNIX AIX? I tried TZ=XYZ+24 date '+%y%m%d' But it doesn't understand Thanks for contribution (6 Replies)
Discussion started by: digioleg54
6 Replies

2. Shell Programming and Scripting

Get Previous day error from alertlog

Hi All, I want to get the all ORA- related errors from attached logfile for previous day. Pls help. Thanks ! Regards Kamal (7 Replies)
Discussion started by: kamauv234
7 Replies

3. UNIX for Dummies Questions & Answers

List the files of previous day

I am using KSH. d=date | nawk '{ print $2,$3-1}' ls -lrt SystemOut* | nawk '/d/{print $NF}' I am trying to list the files of previous day but it doesn't seem to be working and i am also not getting an error. result is blank.Need help. (11 Replies)
Discussion started by: vagar11
11 Replies

4. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

5. Shell Programming and Scripting

Script to check if last modified day is previous day

Hi, I would like to write a script that checks if a file ('counter') was modified the previous day, if so erase its contents and write 00000000 into it. For e.g. if the file 'counter' was last modified at 11.30pm on 24th May and the script runs at 12.15am of 25th May, it should erase it's... (1 Reply)
Discussion started by: hegdepras
1 Replies

6. Shell Programming and Scripting

getting previous day.

Hi, i am developing a script for my project. In my script i need to check some conditions based upon some values. in that one value is the previous date. with the previous date i need to check and process some values. I have a function with me retrieve the yesterdays date. But now i have a... (6 Replies)
Discussion started by: intiraju
6 Replies

7. Shell Programming and Scripting

Script to find previous month last day minus one day timestamp

Hi All, I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this. My Requirment is as below: Input for me will be 2000909(YYYYMM) I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Discussion started by: girish.raos
3 Replies

8. Shell Programming and Scripting

Display month for Previous day

Hello - I have one question regarding the date. I wanted to display the month name for previous day. The output should be as follows... 5-Feb-09 => February 1-Feb-09 => January 28-Feb-09=> February Here is the code i am using to get the output.... date '+%m %d %Y' | { read MONTH DAY... (4 Replies)
Discussion started by: govindts
4 Replies

9. Shell Programming and Scripting

next/Previous business day

Hello, Can you please help me how do i get previous and next working day of the week for a given date excluding saturday and sunday. Ex: if the given date is monday, i should get friday and tuesday's date if the given date is friday, i should get thrusday and monday's date. Thanks,... (4 Replies)
Discussion started by: kotasateesh
4 Replies

10. Shell Programming and Scripting

Previous day's date in Perl?

Hi All, I want to find the previous day's date and store that in a variable, which will be usuful for further processing. Any help please. Regards, raju (4 Replies)
Discussion started by: rajus19
4 Replies
Login or Register to Ask a Question