2014-10-17 44 views
0

請幫幫忙,我只能看到論壇上有這個問題的猛砸,KSH和其他如何檢查,輸入不數 - CSH

需要它適用於CSH。

檢查,如果輸入$ 2不是數量,也不提前「所有」一詞

if ($#argv == 2 && ($2 != all && $2 != **any number**)) then 
    echo "wrong parameter" 

謝謝!

+0

你張貼了類似的問題,我回答說:http://stackoverflow.com/questions/26457720/regex-to-check -if-輸入是用戶號碼在-cshunix – supergra 2014-10-23 18:54:22

回答

0

這一個只是搜索characted在_中的任何字母$ 2:

if (($#argv == 2 && $2 != all && `echo $2 | grep -c '[_A-Za-z]') then 
    echo "wrong parameter" 
endif