Shell Script - help Reqd


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script - help Reqd
# 1  
Old 07-08-2009
Shell Script - help Reqd

Hi,
I need someone's help in writing a shell script. Since am very new i am stuck .

I have 2 files in the same dir.

==============================================

FileA

Table1~07/07/2009 00:00:00~4
Table1~07/06/2009 00:00:00~41
Table1~07/08/2009 00:00:00~4

Table2~07/08/2009 00:00:00~4

FileB

Table1~07/07/2009 00:00:00~4
Table1~07/06/2009 00:00:00~44
Table1~07/08/2009 00:00:00~4

Table2~07/08/2009 00:00:00~4

============================================

I am looking to take the data from both files in this manner.
Based on the timestamp i need take the rec, i.e if there are 3 days 6,7 & 8 (8 is today's date) then i need to take the rec of yesterday's i.e.7 (sysdate-1 th rec) from both files.

Table1 from both files for date 7 & at the end in file is the count (i.e 41 in fileA & 44 in fileB) are the counts.

I need to find the difference of them (fileB - fileA)
& i need the o/p in this format :

Table1 3 (in a new file)

so steps are :

Grep for recs with sysdate - 1st rec
Take the Tb name & count from both files
Take the difference of fileA & fileB count
Print it in a new file.

If some one can help me out in this, it would be of great help.

I tried like this :

I had 2 files a and b

a :

SVC_REQ_CNT~07/05/2009 00:00:00~16
SVC_REQ_CNT~07/06/2009 00:00:00~10
SVC_REQ_CNT~07/07/2009 00:00:00~18

SVC_ORD_CNT~01/22/2098 00:00:00~2
SVC_ORD_CNT~02/04/2099 00:00:00~2
SVC_ORD_CNT~07/07/2009 00:00:00~1


b :

SVC_REQ_CNT~07/05/2009 00:00:00~16
SVC_REQ_CNT~07/06/2009 00:00:00~10
SVC_REQ_CNT~07/07/2009 00:00:00~19

SVC_ORD_CNT~01/22/2098 00:00:00~2
SVC_ORD_CNT~02/04/2099 00:00:00~2
SVC_ORD_CNT~07/07/2009 00:00:00~5


I tried the following :

grep `TZ=aaa24 date +\%m/%d/%Y` a | cut -d '~' -f 3-4

o/p :

18
1


grep `TZ=aaa24 date +\%m/%d/%Y` b | cut -d '~' -f 3-4

19
5

Now i have to proceed further. Take the diff & put it in a new file along with the tb name ..

Thanks,
Vijay.

Last edited by vijayarajvp; 07-08-2009 at 03:24 AM..
# 2  
Old 07-08-2009
what have you tried till now??
# 3  
Old 07-08-2009
You seem to be clear in what you want.. where exactly are you stuck.
# 4  
Old 07-08-2009
I tried like this :

I had 2 files a and b

a :

SVC_REQ_CNT~07/05/2009 00:00:00~16
SVC_REQ_CNT~07/06/2009 00:00:00~10
SVC_REQ_CNT~07/07/2009 00:00:00~18

SVC_ORD_CNT~01/22/2098 00:00:00~2
SVC_ORD_CNT~02/04/2099 00:00:00~2
SVC_ORD_CNT~07/07/2009 00:00:00~1


b :

SVC_REQ_CNT~07/05/2009 00:00:00~16
SVC_REQ_CNT~07/06/2009 00:00:00~10
SVC_REQ_CNT~07/07/2009 00:00:00~19

SVC_ORD_CNT~01/22/2098 00:00:00~2
SVC_ORD_CNT~02/04/2099 00:00:00~2
SVC_ORD_CNT~07/07/2009 00:00:00~5


I tried the following :

grep `TZ=aaa24 date +\%m/%d/%Y` a | cut -d '~' -f 3-4

o/p :

18
1


grep `TZ=aaa24 date +\%m/%d/%Y` b | cut -d '~' -f 3-4

19
5

Now i have to proceed further. Take the diff & put it in a new file along with the tb name ..
# 5  
Old 07-08-2009
Are you cheching the largest value for the count?
Are 18,1 and 19,5 not counts you needed, am confused...
# 6  
Old 07-08-2009
Hello,

Per our forum rules, all threads must have a descriptive subject text. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt". Post subjects like "Execution Problems with Cron" or "Help with Backup Shell Script".

The reason for this is that nearly 95% of all visitors to this site come here because they are referred by a search engine. In order for future searches on your post (with answers) to work well, the subject field must be something useful and related to the problem!

In addition, current forum users who are kind enough to answer questions should be able to understand the essence of your query at first glance.

So, as a benefit and courtesy to current and future knowledge seekers, please be careful with your subject text. You might receive a forum infraction if you don't pay attention to this.

Thank you.

The UNIX and Linux Forums
# 7  
Old 07-08-2009
am nor checking for the largest value. I have to take the counts from both files a and b & subtract (b-a) to take the count & place the o/p value in a new file.

i.e. 19-18 = 1
5-1=4

the o/p file shud contain

SVC_REQ_CNT~1
SVC_ORD_CNT~4
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

unable to grep the reqd field

hi all, i have a data sm thg like this 28504 0 abc 148782859 42 101M nhmmmm ilopo abc 2345432 i want to get only the field which is just aftr abc i,e., 148782859, 2345432 i have used grep /abc\t/ filename to get that but its not working can any 1 help me out (5 Replies)
Discussion started by: anurupa777
5 Replies

2. Shell Programming and Scripting

Explanation reqd for the Unix file

Hi, I have a unix file with the following contents #/usr/bin/sh cd /ct/mr/prod/bin ncm_AdjCob.pl -a /ct/mr/prod/wg/applog_AdjDev.log -c /ct/mr/prod/lib/config/bcmp_AdjDevCob.conf -s /ct/mr/prod/log/syslog can anyone explain what it says. particularly -a ,-c... (5 Replies)
Discussion started by: psthariharan
5 Replies

3. Shell Programming and Scripting

Help reqd in shell scripting..

Hi guys, I am new to shell scripting and I need urgent assistance. I have an xml like : <AgreementNumberFull>13-WY-84252</AgreementNumberFull> <AgreementNumberAbbr>WY84252</AgreementNumberAbbr> <LineOfBusiness>F</LineOfBusiness> <CompanyCode>0005</CompanyCode> <UniqDigit/> <StateCode/> ... (9 Replies)
Discussion started by: puneetkanchi
9 Replies

4. Shell Programming and Scripting

Explanation reqd

Hi, i have a script of following content #!/usr/bin/sh 'exit 255' USR1 ncm_CheckDir.pl -a /cnt/mgr/test/working/applog_CheckDir.log -c /cnt/mgr/test/lib/config/bp_CheckDir.conf -s /cnt/mgr/test/log/syslog filename : BC_CheckDir when i execute ie : sh BC_CheckDir i am getting... (11 Replies)
Discussion started by: psthariharan
11 Replies

5. Shell Programming and Scripting

shell script reqd - deleting files

I have written a script that deletes files: Requirement: i need to delete the files and to know how many files are deleted i.e the count of files and even i need to display when the started time of deletion and the ending time of deletion. I need to display these two times. script: ... (2 Replies)
Discussion started by: venkatesht
2 Replies

6. Shell Programming and Scripting

unix shell script reqd...

Task: Short Description: To find the files in a particular directory for the previous day, sort them by date and time and e-mail it across to a particular id. And the time is divided into eight fields and based on the time the respective field should be updated with the flag 1. Eight... (7 Replies)
Discussion started by: venkatesht
7 Replies

7. Shell Programming and Scripting

AWK help reqd

Hi, I have below requirement that I need to do it using AWK. Files ==== File1: data file that has thousands of recs File2: Lookup file I need to compare the position 21-31 of File1 with 1-11 of File2. If matched then write to new output file(outfile1) else write to another output... (17 Replies)
Discussion started by: Sathy153
17 Replies

8. Shell Programming and Scripting

Checklist for Shell Script reqd

Hi, Can anyone provide me with the Code Review Checklist for Shell scripts ?? Thanks in advance. (2 Replies)
Discussion started by: Shivdatta
2 Replies

9. HP-UX

command reference sheet reqd.

hi everybody, i m AIX guy.... due 2 some reason i was also askd 2 work in HP-UX so i think all d concepts r same as AIX.... so i thought it s easy to learn by comparitve study.... if so then wr can i get the materials???????? thanks in advance........ (1 Reply)
Discussion started by: rrlog
1 Replies

10. HP-UX

Help Reqd

Hi I am facing the problem where my HP Unix system date is in accordance with the current date but the logs written by the same is of previous time stamp. Eg. System Date - Thu Mar 15 18:00:04 IST 2007 Syslogs - Mar 15 12:30:10 mac@1 ftpd: FTP LOGIN FROM xx.xxx.xxx.xx , main The ftp... (1 Reply)
Discussion started by: PradeepRed
1 Replies
Login or Register to Ask a Question