extracting substring from a file name

hi

i need to name a file with a substring of a another file name.

i.e. if the old filename is abc.txt , the new filename should be abc_1.txt
i should get the substring of the file name and then name the new one

please let me know how to do it

Try this:

#!/bin/sh
F=abc.txt
F1="${F%.*}_1.${F##*.}"
echo "F1=$F1"

The "%." (percent period asterisk) strips off exactly one period and the remaining characters from the end.
The "##
." (pound pound asterisk period) strips off all characters up to the last period plus the period from the front.

try this out

t1=`basename $0 .txt`
t2=${t1}_1.txt
echo "new file name:-${t2}"

thanks a lot !!!!
its working

Another way ...

$ F=abc.txt
$ F1=${F/\./_1\.}
$ echo $F1
abc_1.txt