Sponsored Content
Top Forums Shell Programming and Scripting Alternative to the loop is needed Post 302656647 by niladri29 on Friday 15th of June 2012 10:40:01 AM
Old 06-15-2012
Alternative to the loop is needed

I have a file containing ids like this (file1):
Code:
c9e2c3c6c100000000460000c02000803c63e529c3f5f5f0
c9e2c3c6c100000000460000c02002813c63e539c3f5f5f0
c9e2c3c6c100000000460000c02002ee3c63ebb1c3f5f5f4
c9e2c3c6c100000000460000c020042f3c63e549c3f5f5f0

These ids are present in muiltiple files named: id1 id1 id3 etc,
To find all occurances of values of file1 in id1,id2 etc, I have used:
Code:
fgrep -f file1 id* > idout

Now for each line in file1 (eg, line 1:c9e2c3c6c100000000460000c02000803c63e529c3f5f5f) there should be 2 entries in file idout, like:
Code:
Central-Perf-21-0:lppza087; [2012-06-12 21:00:02,463] <PERFA  > JMSId :ID:c9e2c3c6c100000000460000c02000803c63e529c3f5f5f0 SvcName :realtime.xltr.FASERInquire                                                                   OO [MessageListenerThreadPool : 15  ] OO xltrmdb.XltrFASERInquireMDB       OO                       logEntry() OO Entry into MDB id:9 and message object id 2071362422
Central-Perf-21-0:lppza087; [2012-06-12 21:00:02,606] <PERFA  > JMSId :c9e2c3c6c100000000460000c02000803c63e529c3f5f5f0 SvcName :realtime.xltr.FASERInquire Card :123456789123456 SrcCd :WEB                                  OO [MessageListenerThreadPool : 15  ] OO xltrmdb.XltrFASERInquireMDB       OO                        logExit() OO Return from MDB id:9 and message object id 2071362422
To be noted : (c9e2c3c6c100000000460000c02000803c63e529c3f5f5f0,2071362422)

for every two lines will be unique, like they a pair.
But there will also be few lines of file1 which will have only a single entry in idout file,like:
Code:
Central-Perf-21-0:lppza087; [2012-06-12 21:00:02,463] <PERFA  > JMSId :ID:c9e2c3c6c100000000460000c020042f3c63e549c3f5f5f0 SvcName :realtime.xltr.FASERInquire                                                                   OO [MessageListenerThreadPool : 15  ] OO xltrmdb.XltrFASERInquireMDB       OO                       logEntry() OO Entry into MDB id:9 and message object id 2111111111

Requirement:
a)How to remove (separate out). the single lines? (as depicted above)

b)How to find time lag, like (diff of 2012-06-12 21:00:02,463 and 2012-06-12 21:00:02,606) depiected above for 2 consecutive lines? Need to ensure that the lines must be of same JMS id and message id)
N.B: A loop on file1 can be executed to find occurances in id* files;.Also the time diff (subtraction) can be done in the loop.But that is not feasible due to severe time constraint as the data volume is very high.

regards,
niladri
Moderator's Comments:
Mod Comment please use code tags to allow us to read data and code


---------- Post updated at 08:10 PM ---------- Previous update was at 04:08 PM ----------

Hi Gurus,
Any hints?

thanks,
Niladri

Last edited by jim mcnamara; 06-15-2012 at 08:35 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

loop alternative?

I have a 1-column file with random numbers. this script runs to subtract 1 to the number and written to a file. With over 10,000 lines, it takes >2 minutes to complete the loop operation. is there an alternative awk/sed for looping to reduce the wait? Thanks! #!/bin/ksh for N in `cat... (2 Replies)
Discussion started by: apalex
2 Replies

2. UNIX for Dummies Questions & Answers

Alternative for a while read line loop

HELLO all :), I have been trying to use a simple while loop to read a file " templist", line by line and perform an action. See the code below. The reason for not using a while read line loop is the for the use of the if condition that wouldn't work. I would appreciate some ideas as this has... (2 Replies)
Discussion started by: kabs
2 Replies

3. Shell Programming and Scripting

help with while loop or any other alternative?

i=1 while do mm=02 dd=03 yy=2008 echo "$mm$dd$yy" i=$(( i+1)) echo "$i" done whenever i execute the script above i will get the error below: syntax error at line 30: `i=$' unexpected (3 Replies)
Discussion started by: filthymonk
3 Replies

4. UNIX for Dummies Questions & Answers

For loop help needed

Hi there, i want to direct the out put return from the FOR loop statement to any log file. code copied below. for file in `ls *.in` do ... ... done if there is no file then i need to write the log to one file. Thanks Arun (3 Replies)
Discussion started by: arund_01
3 Replies

5. Shell Programming and Scripting

loop needed?

Hi All, thanks in advance for any help you can give me. I'm trying to get some error checking of a username in my shell script. While I have that part under control, at the moment my script just exits if the username entered doesn't match the correct syntax. I've been googling to try and... (4 Replies)
Discussion started by: adarii
4 Replies

6. UNIX for Advanced & Expert Users

Alternative needed for joining lines with a match

Hi, The following sed command is not working for me, does anyone have a good alternative for joining lines in a file based on a match? # if a line ends with a backslash, append the next line to it sed -e :a -e '/\\$/N; s/\\\n//; ta' (6 Replies)
Discussion started by: greptastic
6 Replies

7. Shell Programming and Scripting

if loop help needed

Dear All, Please help me out for the below query echo 'please input file type (i.e file1,file2,file3,file4): ' read a cat hello.wri | grep $a | wc -l > temp1.wri cat hello.wri | grep $a | wc -l > temp2.wri cat hello.wri | grep $a | wc -l > temp3.wri cat hello.wri | grep $a | wc -l >... (1 Reply)
Discussion started by: jojo123
1 Replies

8. Shell Programming and Scripting

While Loop Syntax help needed

Hi everyone, Can ny1 help me out regarding while loop arguments i.e. what does -gt -ge -lt -le means? actually i am new to while loops (2 Replies)
Discussion started by: jojo123
2 Replies

9. Shell Programming and Scripting

'for' loop advice needed ....!!

/usr/sbin/ifconfig -a | grep "inet" | grep -v "inet6" | grep -v "127.0.0.1" | grep -v "0.0.0.0"|grep -v "192.168.100.2" | awk '{print $2}' I use above command to get IP addresses on AIX boxes.Values coming here are set to a variable "Host IPs.IP Addresses" in my fingerprinting engine. ... (4 Replies)
Discussion started by: ak835
4 Replies

10. UNIX for Advanced & Expert Users

'for' loop advice needed....!!

Scenario: Command used to capture IPs on a host: /usr/sbin/ifconfig -a | grep "inet" | egrep -v "inet6|0.0.0.0|192.168.100.2" | awk '{print $2}' Following for loop used to capture interface names: for INTERFACE in `/usr/sbin/ifconfig -a | nawk '$1 ~ /:$/ && $1 {sub(":$", "", $1); print... (3 Replies)
Discussion started by: ak835
3 Replies
All times are GMT -4. The time now is 06:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy