I have variable which has value \"abcd.txt\".
\"abcd.txt\"
I want to store everything before the \".txt\" in a second variable, replacing the \".t
\".txt\"
\".t
You can use command substitution as:
new_filename=$(echo "$a" | sed 's/.txt/.log/')
or the less recommended backtick way:
new_filename=`echo "$a" | sed 's/.txt/.log/'`