What I have is this:
progname=${0%.*}
progname=${progname##*/}
Can this be nested (or not) into one line, i.e. a single expression?
I’m trying to strip the path and extension off of a script name so that only the base name is left. The above two lines work fine. My ‘C’ nature is simply driving me to obfuscate these even more.
If by nest, you mean something like this:
Then no, you can’t nest
${var}expressions. The bash syntax expander won’t understand it.However, if I understand your problem right, you might look at using the
basenamecommand – it strips the path from a given filename, and if given the extension, will strip that also. For example, runningbasename /some/path/to/script.sh .shwill returnscript.