hi
i want to replace the characters between positions 2 to 30 in each line in a file
how to do it
suggestions welcome
using Perl:
perl -pi -e 's/(.).{29}(.*)/\1hoohaa\2/' filename
(.) - capture single character (the first character on line)
.{29} - next 29 characters on line
(.*) - capture remaining characters on the line
hoohaa - replacement text
If a line contains less than 30 characters, it remains unaffected
# awk '{ print substr($0,1,1)"replace_string"substr($0,31)}' file