## * / use in UNIX shell scripts

Can anyone explain how ## * / works in UNIX Shell scripts. I saw its use in Korn Shell. It is specially used to remove the file extension.

eg. func_write_app_log "o Deleting the status file $ {CIE_STATUS_FILE ## * /}"

Here, suppose the file is CIE_STATUS_FILE.DAT, then ## * / will display CIE_STATUS_FILE

+3
source share
1 answer

This also works in Bash and is described here :

$ {line ## substring}

Removes the most matching $ substring from the string $ string.

*is a wildcard that matches any. Your example removes the path from the file, not the extension.

$ bazfile='/foo/bar/baz.txt'
$ echo ${bazfile##*/}
baz.txt

, %:

${% }

$substring $string.

$ echo ${bazfile%.*}
/foo/bar/baz
+5

Source: https://habr.com/ru/post/1756927/


All Articles