I would like to extract the filename (root) from a file with specific extension (.datt). This file is the only single file in my directory but could change its root name but extension remains fixed; therefore I need to use a "wildcard" to capture the name. Here is my little script that incorrectly outputs all the files. Appreciate your help.
# Target file in the folder >> test.datt
myfile=*.datt
echo $myfile
echo
root="${myfile%.datt}"
echo $root
My output
test.datt
temp test.datt testroot
Expected output
test