FreeOZ论坛

标题: shell script 又学了一招 [打印本页]

作者: fargo    时间: 4-3-2010 22:38
提示: 作者被禁止或删除, 无法发言 标题: shell script 又学了一招
shell 编程还是ksh 好,bash没有这些功能。

1)match any three digits

#!/bin/ksh
if [[ $1 = {3}(\d) ]]; then
echo Match
fi

2) match Low or HiGh case-insensitive
normal sh/bash usage: [ $1 = low -o $1 = high ], case-insensitive need shell option nocasematch enabled

#!/bin/ksh
if [[ $1 = @(~(i:low|high)) ]]; then
echo Match
fi


more info "man ksh"


?(pattern-list )
Optionally matches any one of the given patterns.
*(pattern-list )
Matches zero or more occurrences of the given patterns.
+(pattern-list )
Matches one or more occurrences of the given patterns.
{n }(pattern-list )
Matches n  occurrences of the given patterns.
{m ,n }(pattern-list )
Matches from m  to n  occurrences of the given patterns. If m  is omitted, 0 will be used. If n  is omitted at least m  occurrences will be matched.
@(pattern-list )
Matches exactly one of the given patterns.

!(pattern-list )
Matches anything except one of the given patterns
作者: syfool    时间: 8-3-2010 12:57
提示: 作者被禁止或删除, 无法发言 perl不错
作者: ljbit    时间: 8-3-2010 13:17
python也不错




欢迎光临 FreeOZ论坛 (https://www.freeoz.org/bbs/) Powered by Discuz! X3.2