I am new to unix. I want to delete 2 words placed at position say for example at 23rd and 45th position in a line. I used sed but couldnt achieve this.
Example: the file contains 2 lines
12345 98765 "12345" 876
12345 98765 "64578" 876
I want to delete " placed at position 13 and 19 in both lines.
sed -r "s/^(.{12})(.{1})/\1/" filename | sed -r "s/^(.{17})(.{1})/\1/"
The first sed:
/^(.{12})(.{1})/ means select 1 ((.{1})) character that comes after the first (^) 12 characters ((.{12}))
/\1/ means keep portion before the selection and replace the selection with nothing. That takes care of the first ".
The second sed simillarly removes the second " (which by the way is not in position 19 anymore, it's character number 18 and hence the option (.{17}))