Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. P1
  2. 10,9:11/18013013582
  3. ,10:1
  4. ,167:0
  5. ,487:5/E.164
  6. 11,9:15/310410532169026
  7. ,10:60
  8. ,167:0
  9. ,487:4/IMSI
  10. 12,18:15/013329002130500
  11. ,19:0
  12. 15,9:10/9609610015
  13. ,10:1
  14. ,14:68
  15. ,167:0
  16. ,436:5/ABCDE
  17. ,487:5/E.164
  18. 16,87:1
  19. 17,9:10/8013765024
  20. ,10:1
  21. ,11:1
  22. ,12:0
  23. ,167:0
  24. ,487:5/E.164
  25. 23,9:11/13123149810
  26. ,10:1
  27. ,11:1
  28. ,167:0
  29. ,487:5/E.164
  30. P3
  31. 42,3:1.
  32. ,4:3
  33. ,300:1.
  34. 43,3:1.
  35. ,4:3
  36. ,300:1.
  37. 44,3:0.
  38. ,4:7
  39. ,300:0.
  40. 45,5:0.3
  41.  
  42. nawk -v fname="${filename}" -F '/|:' '
  43.  
  44. function isnum(x){return(x==x+0)}
  45.  
  46. /P1/,/P3/{
  47. # Found start increment i reset variables go to next line
  48. if(/P1/){
  49. ++i
  50. fid =""
  51. count++
  52. next
  53. }
  54.  
  55. # Found end validate variable and print go to next line
  56. if(/P3/){
  57. printf "%s|",count
  58. printf "%s|",isnum(fid)?fid:"NULL"
  59. next
  60. }
  61. if(!fid && /36,59:*/)
  62. {
  63. fid = $NF
  64. }
  65. ' ${filename} >>output.txt
  66.  
  67. 17[,0-9:]*[n]*,11
  68.  
  69. $ awk -F/ '$2~/^80/{print; getline; print; getline; $1=",11.2"}1' file1.txt
  70. P1
  71. 10,9:11/18013013582
  72. ,10:1
  73. ,167:0
  74. ,487:5/E.164
  75. 11,9:15/310410532169026
  76. ,10:60
  77. ,167:0
  78. ,487:4/IMSI
  79. 12,18:15/013329002130500
  80. ,19:0
  81. 15,9:10/9609610015
  82. ,10:1
  83. ,14:68
  84. ,167:0
  85. ,436:5/ABCDE
  86. ,487:5/E.164
  87. 16,87:1
  88. 17,9:10/8013765024
  89. ,10:1
  90. ,11.2
  91. ,12:0
  92. ,167:0
  93. ,487:5/E.164
  94. 23,9:11/13123149810
  95. ,10:1
  96. ,11:1
  97. ,167:0
  98. ,487:5/E.164
  99. P3
  100. 42,3:1.
  101. ,4:3
  102. ,300:1.
  103. 43,3:1.
  104. ,4:3
  105. ,300:1.
  106. 44,3:0.
  107. ,4:7
  108. ,300:0.
  109. 45,5:0.3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement