Extract specific read from a data

Input file:

#abc_1
SAASFASFGGDSGDSGDSGSDGSDGSDGSDGSDGSDGSDGDS

Output file:

FASFGGDSGDS

I just want to print out the read from position 5 until position 15 from the data.

Below is the code that I just try but it is failed to get my desired output:

grep -v '#' input_file | awk '{print substr($0,5,15)}'

Thanks for any advice.

 echo "SAASFASFGGDSGDSGDSGSDGSDGSDGSDGSDGSDGSDGDS" | cut -c 5-15

Hi ni2,
Thanks for your suggestion.
But I think it seems like not a good solution by using "echo" and "cut" if I got long list of input data and only extract small portion from it :frowning:

awk '! /^#/ { print substr($1, 5, 11) }' input_file

The third argument to substr, if supplied, is the length, not the end point of the string.

thanks scottn,
your suggestion work nice for my problem.

You can still use cut for this.

 
$ cat abc_1
SAASFASFGGDSGDSGDSGSDGSDGSDGSDGSDGSDGSDGDS
SAAASFGGDSGDSGDSGSDGSDGSDGSDGSDGSDGSDGDS
SAAFGGDSGDSGDSGSDGSDGSDGSDGSDGSDGSDGDS
 
$ cut -c 5-15 abc_1
FASFGGDSGDS
SFGGDSGDSGD
GGDSGDSGDSG