need shell script to get last 10 char from a file name and write in to a new file

i have no idea abount shell script but i need need shell script to get last 10 char from a file name and write in to a new file.

consider u hav 5 files in a particular dir i script should get last 10 char of each file n write the 10 char in separate files

If the last ten characters are all on one line,

sed -n '$s/.*\(..........\)$/\1/p' file

If you might have embedded newlines among those last ten characters, a different approach is needed.

To loop over all files and do each in turn,

for f in /path/to/directory/*; do
  sed -n '$s/.*\(..........\)$/\1/p' "$f" >"$f".new
done

This will create a new file next to each old file, with the extension ".new" added to the end of the file name.

you said to get last 10 char from a file name, or is it last 10 char of file content? if its file name

file="testfile1234567890"
echo $file | cut -c10-

if its last 10 char of file content

tail -c10 filename