I am very new to bash. Therefore, if this is a fairly simple question, please forgive me.
I am trying to replace the file extension ' .gzip
' with ' .gz
'.
eg:.
testfile.xml.gzip => testfile.xml.gz
Someone wrote a script that does this:
GZIP=`echo ${FILE} | grep .gz` . . . FILE=`echo ${FILE} | sed 's/.gz//g'`
The first line mistakenly corresponds to the testfile.xml.gzip
file. grep .gz
matches the text in the file name that is between them, whereas I need it to match only if it is at the end of the file name. Can someone help me in solving this problem? In short, I need to know an expression that matches the pattern at the end of a line / text.
source share