Use of %? in unix -
i new unix, can please tell me purpose of '%?' in below command:
-bash-3.2$ sample=test123 -bash-3.2$ sample=${sample%?} -bash-3.2$ echo $sample test12
i can see removing last character can remove many characters want, example 3 charactes etc.
it's pattern matching operator, meaning "if pattern matches end of variable's value, delete shortest part matches , return rest". since ?
matches "any single character", last character removed.
so if want remove 3 characters, need replace ?
expression matches 3 characters instead of one.
Comments
Post a Comment