Reputation: 9982
Since shell scripting uses one character operators that are very common they are very difficult to google, so I ask here. I have the following line in a shell script:
marvel_dir=${prototxt%marvel*}marvel
where prototxt is the complete path and filename of a prototxt file.
My question is what does "%" do there? How about "*"?
Upvotes: 0
Views: 28
Reputation: 101
When the percent sign (%) is used in the pattern ${variable%substring}, it will return content of the variable with the shortest occurrence of substring deleted from the back of the variable.
Upvotes: 3