我们有一个 ksh 脚本,它应该将输出作为月份最后一天,但是每当我们运行它时都会收到以下错误:
cut: fields are numbered from 1
Try ‘cut —help’ for more information,
我一直试图调试这个问题,但无法成功。
以下是代码:
#!/usr/bin/ksh
if (( $(#) <= 1 )) ; then print "${0##*/} <two-digit month> <four-digit year›" ; exit 101 ; fi
typeset -Z2 month=${1}
typeset -Z4 year=${2}
typeset -i whencecal=$(whence cal 2>/dev/null | wc - l)
if (( whencecal != 1 )) ; then print "FATAL: \"cal\" command not found!" ; exit 102 ; fi
typeset -i wrdcount=$(cal ${month} ${year} | sed -e "/^$/ d" | tail -1 | wc -w)
typeset -Z2 momaxdate=$(cal ${month} ${year} | sed -e “/^$/ d” -e “s/[ ][ ]*/,/g” | tail -1 | cut -d”,” -f${wrdcount})
print ${momaxdate}
如何解决此问题