Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to be able to use sed (or anything else) to replace a specific line position, I'm Googleing and can't find anything (yet).


this is what I came up so far..

sed 's|\(^.\{67\}\).\{1\}||g' $$

yet this deletes everything from beginning to position 67+1, I want ONLY position 67+1 to be gone..

share|improve this question
so you want the first character on line 67 to be deleted? – Mike Jun 20 '13 at 15:16
no, I want position 67 and position 68 to be gone.. – alexus Jun 20 '13 at 15:26
up vote 2 down vote accepted

I first believed youd need this. This will match 66 characters \(.\{66\}\) and store it in \1, put the next two \(.\{2\}\) in \2, and everything else \(.*\) in \3 it will substitute \1\2\3 with \1\3, disappearing you 2 characters you dont want.

sed 's/^\(.\{66\}\)\(.\{2\}\)\(.*\)/\1\3/'

And then I remembered this. This will substitute 2 characters '..' for '' at character 67.

sed 's/..//67'
share|improve this answer
it works, but if you don't mind can you explain it please?) – alexus Jun 20 '13 at 16:58
@alexus explained – Sirch Jun 20 '13 at 19:28
thanks so much!) – alexus Jun 20 '13 at 20:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.