1

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).

* UPDATE *

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..

2
  • 1
    so you want the first character on line 67 to be deleted?
    – Mike
    Jun 20, 2013 at 15:16
  • no, I want position 67 and position 68 to be gone..
    – alexus
    Jun 20, 2013 at 15:26

1 Answer 1

2

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'
2
  • it works, but if you don't mind can you explain it please?)
    – alexus
    Jun 20, 2013 at 16:58
  • @alexus explained
    – Sirch
    Jun 20, 2013 at 19:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .