1. switch 的用法,注意每一个 case 必须要以 breaksw 结尾
否则会继续执行下一个 case 的命令
(1) 另外, $<的意思是取得使用者的 stand input
(2) echo 若加上 -n 的选项,则游标会停留在该行最后
echo -n "Input one color: "
set STOPLIGHT = $<
switch ($STOPLIGHT)
case red:
echo "red"
breaksw
case orange:
echo "orange"
breaksw
case green:
echo "green"
breaksw
default:
echo "you input $STOPLIGHT"
endsw
--------------------------------------------------------------------
2. 利用 set 来取得变数, set ABC = "I am ABC"
也可以利用 `command` 来取得命令
且外,case 也可以用万用字元 * 来代替
set VER = `uname -r`
switch ($VER)
case 5.5:
echo "run the setup of $VER"
breaksw
case 5.3:
echo "run the setup of $VER"
breaksw
case 5.*:
echo "like 5.x"
breaksw
case 4.*:
echo "like 4.x"
breaksw
default:
echo "no idea"
endsw
--------------------------------------------------------------------
3. if 的语法,比较数字
set n1 = 1
set n2 = 2
if ($n1 == $n2) then
echo "$n1 Equal $n2"
else
echo "$n1 Not Equal $n2"
endif
--------------------------------------------------------------------
4. if 的语法,比较字串
set n1 = abcdef
set n2 = abcde
if ($n1 == $n2) then
echo "$n1 Equal $n2"
else
echo "$n1 Not Equal $n2"
endif
--------------------------------------------------------------------
5. if 的语法,比较相似的字串
set n1 = abcdef
set n2 = abcde
if ($n1 =~ $n2) then
echo "$n1 Like $n2"
else
echo "$n1 Not Like $n2"
endif
--------------------------------------------------------------------
6. if 的语法,比较数字的大小
set n1 = 1
set n2 = 2
if ($n1 > $n2) then
echo "$n1 > $n2"
else
echo "$n1 <$n2"
endif
# mm 等于当天时间的【分钟】数
set mm = `date | cut -d' ' -f4 | cut -d: -f2`
if ( -r $0.out ) then
rm $0.out
touch $0.out
else
touch $0.out
endif
while ( $mm <= 16 )
set mm = `date | cut -d' ' -f4 | cut -d: -f2`
echo "$mm now is `date`"
sleep 60
#e cho "$mm now is `date`" >> $0.out
end
echo "Over" >> $0.out
--------------------------------------------------------------------
8. 一个回圈的范例,并且利用 expr 去作加的动作
回圈的语法如下:
foreach number (1 2 3)
echo $number
end
set counter = 0
while ($counter <= 10)
echo "sleeping for 5 seconds"
sleep 5
counter = `expr $counter + 1 `
end
--------------------------------------------------------------------
12. 一个实际建立一个 ftp server 的程式
里面包括许多应用,相当有参考价值
( 未完成 )
set path = ( /usr/bin /usr/sbin )
#
set true = `grep -c ftp /etc/passwd`
if ( $true == 0 ) then
echo "no ftp user in your system"
echo -n "do you want to create the ftp user? "
set answer = $<
if ($answer == 'y' || $answer == 'Y') then
set maxid = `sort /etc/passwd | tail -1 | cut -d: -f3`
echo $maxid
set newid = `expr $maxid + 1`
echo $newid
echo "/usr/sbin/useradd -d /home1/ftp -u $newid -s /etc/false ftp"
endif
else
echo "Good. Your system already has the ftp user. "
set ftphome = `grep ftp: /etc/passwd | cut -d: -f6`
echo $ftphome
endif
if ( -z $ftphome ) then
echo "ftphome must be non-null"
exit 2
endif
if ( $ftphome == "/usr" || $ftphome == "/" ) then
echo "ftphome can't be / or /usr"
exit 2
endif
# create the ftp home directory
if ( ! -d $ftphome ) then
echo "mkdir $ftphome"
endif
echo "Setting up the ftphome for SunOS `uname -r`"
if ( ! -d $ftphome ) then
echo "mkdir -p $ftphome/usr/bin"
endif
#!/bin/csh -f
echo .................
echo WELCOME to \* TAPE COPY \*
echo .................
echo Enter your name:
# $
set name = $<
echo " "
echo Hi $name \!
set D = `date`
echo Today\'s date is $D[1] $D[2] $D[3]
if ($D[1] == Mon) then
echo -------------------------------------------------------------
echo Today is $D[1]day $name, it\'s time to copy your directorys\!
echo -------------------------------------------------------------
else
echo -------------------------------------------------------------
echo Today is $D[1]day $name, no tape copies today\!
echo -------------------------------------------------------------
endif
if ( -x $FINGER ) then
if ( $#argv == 0 ) then
cat <
---------------------------------
Hahahah ....
---------------------------------
TAG
else
$FINGER "$*"
endif
else
echo "Cannot find finger on this system."
endif
本文介绍了阿里Treebased Deep Match(TDM)的学习笔记,同时回顾了工业界技术发展的几代演进。从基于统计的启发式规则方法到基于内积模型的向量检索方法,再到引入复杂深度学习模型的下一代匹配技术。文章详细解释了基于统计的启发式规则方法和基于内积模型的向量检索方法的原理和应用,并介绍了TDM的背景和优势。最后,文章提到了向量距离和基于向量聚类的索引结构对于加速匹配效率的作用。本文对于理解TDM的学习过程和了解匹配技术的发展具有重要意义。 ...
[详细]