$1和$2表示第一个参数和第二个参数
date --help里边的一段:
Show the local time for 9AM next Friday on the west coast of the US
$ date --date='TZ="America/Los_Angeles" 09:00 next Fri'
--date后边跟得是另外一个日期,不是当前日期,可以指定时区!
脚本好理解,不过那个date的参数不正确,后边还少了一个“`”标号!应该这样:[code]upday=`date --date="$datestr" +%y%m%`[/code]man date :
引用:
DATE STRING The --date=STRING is a mostly free format human readable date string
such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or
even "next Thursday". A date string may contain items indicating cal-\r endar date, time of day, time zone, day of week, relative time, rela-\r tive date, and numbers. An empty string indicates the beginning of the
day. The date string format is more complex than is easily documented
here but is fully described in the info documentation.
wokanhaoziji 于 2011-10-14 18:24:05发表:
4# 西江听月
:0)1 恩 谢谢谢 你
西江听月 于 2011-10-14 11:43:57发表:
$0,$1,$2...都是有特殊含义的变量,google一下吧
wokanhaoziji 于 2011-10-09 11:58:45发表:
哦 是不是 date --date也就是相当于一个变量(时间 自己可以定义格式)
那个参数$1 $2 我知道是参数 不知道怎么用 就是执行脚本的时候后面 跟两个参数 如 . 1.sh 1 2 这样
我试了一下感觉$1 $2 不要也没有关系输出是一样的
from=111
t1=222
to=333
upday=`date --date="$datestr +%y%m%d"`
for daemon in $lists; do
trcfile=/var/log/cabal/"$daemon"_"$upday".trc
backfile=/trc/$upday/"$daemon"_"$uphour".trc
tmpfile=/tmp/backfile
awk -F'|' '{ if ('"$from"' <= $t1 && $t1 < '"$to"') print $1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9"|"$10 }' $trcfile | unix2dos > $tmpfile
这个脚本看着没有问题 说打不开/var/log/cabal/"$daemon"_"$upday".trc
文件是怎么回事
gogo11 于 2011-10-09 11:36:23发表:
[i=s] 本帖最后由 gogo11 于 2011-10-9 11:44 编辑 [/i]
$1和$2表示第一个参数和第二个参数
date --help里边的一段:
Show the local time for 9AM next Friday on the west coast of the US
$ date --date='TZ="America/Los_Angeles" 09:00 next Fri'
--date后边跟得是另外一个日期,不是当前日期,可以指定时区!
脚本好理解,不过那个date的参数不正确,后边还少了一个“`”标号!应该这样:[code]upday=`date --date="$datestr" +%y%m%`[/code]man date :