hi all,
herewith i have a flat file (test.txt) below :
test.txt :
CTI-ProgramStart|VVV2|Program Start|VKGXXXXXXXX|VKGXXXXXX|06/01/22 00:33:49.467|WSSACCCXXXX|VVV21137XXX3|B Program Version:.6.4.5 AgentID:2247 Password: Signature: Extention:7950 PeripheralID:2 SideAHost:109.XX.XX.XX SideBHost:192.XX.XX.XX SideAPort:42027 SideBPort:5874 HEARTBEATINTERVAL:-1 EXPECTEDCLIENTS:150 QUEUESIZE:32 POOLSIZE=64 SERVICESMASK:-214749088 EVENTSMASK:311071 STATUSMASK:1031 TRACEMASK:5|
i would like to get ext = 7950
BEGIN {
FS="[|]"
}
$1 == "CTI-ProgramStart" {
if( match($9, /Extention:[0-9][0-9]*/) ) {
str=substr($9, RSTART, RLENGTH)
ext=substr(str, index(str, ":")+1)
print ext
}
}
Note : u have to read the flat file fisrt before insert the algorithm.
Tuesday, September 8, 2009
how to use awk | substr
Labels: shell script
Posted by joe is my nick name at 4:16 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment