- 论坛徽章:
- 0
|
我重写了下这个脚本,发现一个很诡异的问题, 我的第二个if语句在首次判断时总是异常, 谁可以告诉下问题出在那里了。
我的系统版本ubuntu 9.10
Linux xxxx-laptop 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12 05:23:09 UTC 2010 i686 GNU/Linux- echo "20100423" | awk '{ i=0; j=0;
- mon = substr( $1, 5,2 )
- year = substr( $1, 1,4 )
- d = substr( $1, 7 )
- print $1
- while("cal $mon $year "| getline)
- {
- i++;
- if(i<3)
- continue
- j = j+NF
- if(d>j)
- continue
-
- for( k=1; k<=NF; k++ )
- {
- if( i == 3 -a d==j-NF+k )
- {
- week = ( 7 - NF + k -1)
- break
- }
- else if(d==j-NF+k)
- {
- week = k == 1? 7: k-1
- break
- }
- else
- }
- print "got here" "j is " j
- print week
- #break
- }
- }'
复制代码20100423
got herej is 3
got herej is 24
5
got herej is 30
5
got herej is 30
5 |
|