Hitachi

Job Management Partner 1 Version 10 Job Management Partner 1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide


5.1.8 Pattern matching

In JP1/Advanced Shell, you can compare patterns in some of the standard commands and script control statements. For example, if the format ${variable#pattern} is used, the shortest part of the variable value that matches the pattern pattern is deleted and then the remainder of the value is set in variable. The following shows an example.

Example:
$ var=abcd
$ echo ${var#a[b]}
cd

Whether a variable value can be compared with a specified pattern depends on the function. If the format of the pattern is invalid, the pattern is treated as a normal character string during comparison. For example, [a*(b] treats all [, *(, and ], which normally have a special meaning as a pattern, as normal characters. The following shows an example.

Example:
$ var='[a*(b])cd'
$ echo ${var#[a*(b])}
cd