##*/ use in UNIX Shell Scripting -
Can anyone explain how ## * / UNIX shell works in scripting? I have seen that it uses corn Is in the shell. This is used specifically to remove the file extension.
For example, "Func_write_app_log" is being removed from the $ {CIE_STATUS_FILE ## * /} status file
Assume that the file is CIE_STATUS_FILE.DAT, then ## * / CIE_STATUS_FILE
This also works in Bash and is described as:
< P> $ {string ## substring}$ removes the longest match of the substring from the front of the string.
is a wildcard which means Anything matches. Your example removes the path from the file, the extension No.
$ bazfile = '/ foo / bar / baz.txt' $ echo $ {bazfile ## * /} baz.txt
the extension you want to use To delete it, %
:
$ {string% substring}
removes at least the $ string of the substring $ string Back.
$ echo $ {bazfile%. *} / Foo / bar / baz
Comments
Post a Comment