Part of string with script

Hi All,
I have few files named.
abcd.docx
abcde.doc
abcdef.temp
I wish if I could extract the string upto .(dot),and not the extension.
Thanks a lot.
Kind regards,
Indranil.

Hi,

Try this one,

cd dir
for i in *
do
   filebase=${i%.*%}
   echo ${filebase}
done

Cheers,
Ranga:-)

thanks.....but i have many files in many sub directories and I want to move all of them to .txt extension.....single line command would be handy......any idea....
thanks for replying.

Hi, you may try this...

for i in `find . -type f `; do dirbase=`dirname ${i}`; fylbase=`basename ${i}`; fylname=${fylbase%.*}; mv ${i} ${dirbase}/${fylname}.txt; done

Try this .. (include the highlighted part if the below command provides expected output)

$ find dir_location -type f | awk -F\. '{print "mv "$0" "$1".txt"}' | sh