fork download
  1. for infile in 111 112 114
  2. do
  3. for year in 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012
  4. do
  5. for month in 1 2 3 4 5 6 7 8 9 10 11 12
  6. do
  7. for day in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
  8. do
  9. gawk -F'\t' 'BEGIN{
  10. average = 0
  11. max = 0
  12. min = 100
  13. count = 0
  14. }
  15. {
  16. for(hour = 1; hour <25; hour = hour+1){
  17. if($1 == "'"${year}"'" && $2 =="'"${month}"'" && $3 =="'"${day}"'" && $4 == hour){
  18. if($5 != 99999){
  19. average = average + $5
  20. count = count +1
  21. if(max < $5){
  22. max = $10
  23. max_hour = hour
  24. }
  25. if(min> $5){
  26. min = $5
  27. min_hour = hour
  28. }
  29. }
  30. else{
  31. count = count
  32. }
  33.  
  34. }
  35. }
  36. }
  37. END{
  38. if(count == 24){
  39. average = average/count
  40. }
  41. else{
  42. average = 99999
  43. max = 99999
  44. min = 99999
  45. }
  46. printf "%4s\t%2s\t%2s\t%7.2f\t%7d\t%7d\n", "'"${year}"'","'"${month}"'","'"${day}"'",average,max,min
  47. }' 1hour/H${infile}.txt >> 1hour/daily/daily_H${infile}.txt
  48. done
  49. done
  50. done
  51. done
Runtime error #stdin #stdout #stderr 0.01s 4272KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
gawk: prog.awk:1: for infile in 111 112 114
gawk: prog.awk:1: ^ syntax error
gawk: prog.awk:2: do
gawk: prog.awk:2: ^ syntax error