Remove text from n position to n position sed/awk

I want to remove text from nth position to nth position couple of times in same line

my line is
"hello is there anyone can help me with this question"

I need like this

ello is there anyone can help me with question

'h' is removed and 'this' removed from the line. I want to do this using positioning...not by replacing.

suggest with me SED /AWK command

use one . symbol for each position in regular expression and use backereferencing mechanism to handle character/string at any position.
For above requirement:

 
echo "hello is there anyone can help me with this question" | sed 's/^\(.\)\(......................................\)\(....\)\(........\)$/\2\4/g'

One . in 1st \( and \) is for very 1st charater and can be backreferenced later using \1
Other dots in 2nd \( and \) is for all other position starting from 2nd charater upto space charater before "this". It will be backreferenced by \2
all dots in 3rd \( and \) is for "this".. and so on
In replace section, \1 (for h) and \3 (for this) is removed so they will not appear in output.
Hope this helps..

try cut.

 cut -c2-39,44-  filename
1 Like

Each line length is not fixed...It may vary.. so Anurag your solution will not fits to my problem.

I want to perform operation across million rows. so awk/sed will provide better performance.

bellow cut command works perfect, will it be faster ?

cut -c2-39,44- text1.txt > remov.txt

Not sure if this helps. Put right count of dots where necessary, else just use .*\
This should be able to handle variable length records

sed 's/^\(.\)\(......................................\)\(....\)\(.*\)$/\2\4/g' text1.txt
 echo "hello is there anyone can help me with this question" |awk '{$1=substr($1,2);$(NF-1)=$NF;$NF=""}1'