Advertisement
Nattack

Untitled

Feb 3rd, 2018
2,079
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 2.41 KB | None | 0 0
  1. RJ Trenchard 100281657
  2.  
  3.  
  4. 1:
  5. #!/usr/bin/awk -f
  6.  
  7. $3 ~ /^M$/ {men++ ;}
  8. $3 ~ /^F$/ {women++;}
  9. END {printf "%.2f\n", men/women}
  10.  
  11. 1.00
  12.  
  13. 2d2bde80c396f9e75c994b2b40787058d4f85b02  -
  14.  
  15. 2:
  16. awk '$8 > 85800 {print NR,$0,$8-85800}' emp.txt
  17.  
  18. 553 Grey Mora M 30 Single 2017 604-555-6855 85827 27
  19. 670 Calvin Porter M 40 Single 2015 604-555-6161 85803 3
  20. 954 Randy Booth M 38 Married 2015 778-555-8544 85898 98
  21. 1170 Keith Bauer M 55 Married 2016 604-555-3164 85816 16
  22. 1554 Ayden Sullivan M 27 Married 2016 778-555-2472 85994 194
  23.  
  24. b91707c3522dad56b12c62e6bc991c523f28f6da  -
  25.  
  26. 3:
  27. #!/usr/bin/awk -f
  28.  
  29. {salary[$3]+=$8; sexes[$3]++}
  30. END {printf "%.2f\n",(salary["M"]/sexes["M"])/(salary["F"]/sexes["F"])}
  31.  
  32. 1.00
  33.  
  34. 2d2bde80c396f9e75c994b2b40787058d4f85b02  -
  35.  
  36. 4:
  37. TODO
  38.  
  39. 5:
  40. #!/usr/bin/awk -f
  41.  
  42. $3~/F/ \
  43. && $4 <= 26 \
  44. && $5~/Single/ \
  45. && $6==2017 \
  46. && $8 < 44000 { printf "%s %s %s\n",$1,$7,$8 }
  47.  
  48. Kaylynn 604-555-1162 43264
  49.  
  50. 4b7a13c7ec327f207e997127c85cd0754c28ab32  -
  51.  
  52. 6:
  53. #!/usr/bin/awk -f
  54.  
  55. $3~/M/ && $4>=35 {next}
  56. $3~/M/ && $4>=25 && $5~/Married/ {next}
  57. $3~/F/ && $4!=36 {next}
  58. {print $0}
  59.  
  60. 338dd3e24004c96c6583325484e31bb3e43a8b46  -
  61.  
  62. 7:
  63. #!/usr/bin/awk -f
  64.  
  65. NR == 1{flSalary = $8}
  66. $8 > clSalary {clSalary = $8}
  67. $8 < flSalary {flSalary = $8}
  68. END {printf "%d\n",clSalary-flSalary}
  69.  
  70. 42934
  71.  
  72. e96255c9054470189a85e97ddc5e38d7a7ed8691  -
  73.  
  74. 8:
  75. #!/usr/bin/awk -f
  76.  
  77. $7~/^(604|778|236)/{phoneCount[substr($7,0,3)]++}
  78. END {printf "%d %d %d\n",phoneCount[604],phoneCount[778],phoneCount[236]}
  79.  
  80. 646 693 661
  81.  
  82. 55688ba0c57d3edf76f425d57a945e4c92eeaf5c  -
  83.  
  84. 9:
  85. #!/usr/bin/awk -f
  86.  
  87. length($2)>=length(longest) {
  88.     if (length($2)>length(longest))
  89.         longest = $2;
  90.     else if ($2 > longest)
  91.         longest = $2;
  92. }
  93. END {print longest}
  94.  
  95. Fitzpatrick
  96.  
  97. 33dbe26e85bdbde8637b760f717b9a2fc503570c  -
  98.  
  99. 10:
  100. #!/usr/bin/awk -f
  101.  
  102. {
  103.     split($7, out, "-")
  104.     subNum[out[3]]++
  105. }
  106.  
  107. END {
  108.     for (i in subNum) {
  109.         if (subNum[i] == 3) sum += i
  110.     }
  111.     print sum
  112. }
  113.  
  114. 35161
  115.  
  116. 41069a47411ebf467a7f5359c8935377a477910d  -
  117.  
  118. 11:
  119.  
  120. TODO
  121. #!/usr/bin/awk -f
  122.  
  123. {
  124.     sumRecord=0;
  125.     for (i = 1; i <= NF; i++)
  126.         sumRecord+=$i
  127.     printf "%.2f\n", sumRecord
  128. }
  129.  
  130. 12:
  131. #!/usr/bin/awk -f
  132.  
  133. {
  134.     split($0, line," ")
  135.     asort(line)
  136.     for (i=1;i<=NF;i++) {
  137.         printf "%.2f", line[i]
  138.         if (i!=NF) printf " "
  139.     }
  140.     print ""
  141. }
  142.  
  143. c416b28b72df920bb4ef98eae124ccaad940bd8f  -
  144.  
  145. 13:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement