Results 1 to 4 of 4
gurus.
I have a file with the following text:
Locks:
Address TranHdl Lockname Type Mode Sts Owner Dur HldCnt Att ReleaseFlg
0x07800000208E0340 3 53514C4332453037DF495EFE41 Internal P ..S G 3 1 ...
- 04-03-2008 #1Just Joined!
- Join Date
- Mar 2008
- Posts
- 5
simple awk question.
gurus.
I have a file with the following text:
Locks:
Address TranHdl Lockname Type Mode Sts Owner Dur HldCnt Att ReleaseFlg
0x07800000208E0340 3 53514C4332453037DF495EFE41 Internal P ..S G 3 1 0 0x0000 0x40000000
0x07800000208DB000 7 53514C4332453037DF495EFE41 Internal P ..S G 7 1 0 0x0000 0x40000000
0x07800000208DA380 7 00000038000000010001A40056 Internal V ..S G 7 1 0 0x0000 0x40000000
0x07800000208DB280 3 0000000200007F0422FB468043 CatCache ..S G 3 1 0 0x0000 0x40000000
0x07800000208E49C0 3 00040101000000000000000054 Table ..X G 3 255 0 0x0000 0x40000000
0x07800000208DC1C0 7 00040101000000000000000054 Table .IS W* 7 1 0 0x0000 0x00000001
I want to be able to print the output as:
7 3 0400 0101
I get the '7' by grepping for W* and printing the $7
I get the '3' by grepping for $2 in the row which has $3 equal to the $3 of the row for which the $7 is W*
0400 --> first 4 characters of $3 of the row for which $7 = W*
0101 --> next 4 characters of $3 of the row for which $7 = W*
I tried doing this but I am doing a mistake somewhere.
Appreciate if someone can send me the complete awk command.
Thanks Gurus.
- 04-04-2008 #2Just Joined!
- Join Date
- Mar 2008
- Posts
- 26
can you print your current awk script here?
Sounds like you could benifit from an awk book :P
- 04-04-2008 #3Just Joined!
- Join Date
- Mar 2008
- Posts
- 5
here is what i want to do.
My input is as below:
Locks:
Address TranHdl Lockname Type Mode Sts Owner Dur HldCnt Att ReleaseFlg
0x07800000208E0340 3 53514C4332453037DF495EFE41 Internal P ..S G 3 1 0 0x0000 0x40000000
0x07800000208DB000 7 53514C4332453037DF495EFE41 Internal P ..S G 7 1 0 0x0000 0x40000000
0x07800000208DA380 7 00000038000000010001A40056 Internal V ..S G 7 1 0 0x0000 0x40000000
0x07800000208DB280 3 0000000200007F0422FB468043 CatCache ..S G 3 1 0 0x0000 0x40000000
0x07800000208E49C0 3 00040101000000000000000054 Table ..X G 3 255 0 0x0000 0x40000000
0x07800000208DC1C0 7 00040101000000000000000054 Table .IS W* 7 1 0 0x0000 0x00000001
example of what I want to do is below:
$ more locks1556528 | awk '$3 == "00040101000000000000000054" {print $0}'
0x07800000208E49C0 3 00040101000000000000000054 Table ..X G 3 255 0 0x0000 0x40000000
0x07800000208DC1C0 7 00040101000000000000000054 Table .IS W* 7 1 0 0x0000 0x00000001
The problem I am trying to solve here is "I do not know the value 00040101000000000000000054" dynamically to compare the $3 with.
So, how do we get this value ? It is $3 for the row in which $6 = W* as shown below:
0x07800000208DC1C0 7 00040101000000000000000054 Table .IS W* 7 1 0 0x0000 0x00000001
I want to print those two rows in which the $3 is same.
But, this value is the $3 for the row in which $6==W*
Please help ! I am lost here with such a presumably simple issue.
It's been days I am fighting with this monster !!!
Thanks.
- 04-07-2008 #4Just Joined!
- Join Date
- Mar 2008
- Posts
- 26
The best way I can think of is to store the $3's in an array and then print matches in the END part of the script.
However, I'm not sure whether AWK is going to be your best tool for this.


Reply With Quote