I need to remove characters from string and then replace other characters. This is the initial string:
something/filename.txt
I need to remove the directory "something" (can be any other name) and replace .txt with .gz The following 2 commmands work perfect:
newfile=${newfile#*/}
newfile=${newfile::-4}.gz
So the output will be: filename.gz Is there a way to do it in a single command? Something like:
${${$newfile#*/}::-4}.gz
With the above command I get: bad substitution error.
Thank you Lucas
${param#*/}and${param::-4}. In${${newfile#*/}::-4}.gz,${newfile#*/}is NOT a parameter. Use 2 parameter expansions and don't worry about combining them.