regex - to check if input is number in csh(unix)
问题 Please help. How to make regex work in an if condition, to check user input(in 2nd parameter) must be not equal to any number? set regex="^[0-9]+$" if ($#argv == 2 && $2 != $regex) then # do this 回答1: grep-based solution that only works for non-negative integers . #!/bin/csh # Note this requires 2 command line arguments, and checks the second one # cshell arguments are 0-indexed. if ($#argv == 2) then # Note the different grep regexp syntax, and you must use single quotes set test = `echo $2