Korn shell Tutorials :Regular Expressions

Korn shell Tutorials :Regular Expressions
Ksh has it's own regular expressions.
Use an * for any string. So to get all the files ending it .c use *.c.
A single character is represented with a ?. So all the files starting with any sign followed bye 44.f can be fetched by: ?44.f.
Especially in ksh there are quantifiers for whole patterns:
?(pattern) matches zero or one times the pattern.
*(pattern) matches any time the pattern.
+(pattern) matches one or more time the pattern.
@(pattern) matches one time the pattern.
!(pattern) matches string without the pattern.
So one can question a string in a variable like: if [[ $var = fo@(?4*67).c ]];then ...

No comments:

Top Blogs