I tried like this,
## Sample file
$ cat a
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
$ cat t.sh
var1=100
var2=200
sed "s/.\{300\}/&$var1$var2/g" a
## see 100200 in output
$sh t.sh
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789010020012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
make clear definition of the word column. column to some may mean fields delimited by some character(s). ie, field 300. Or are you talking about "character position 300 onwards" ?
I mean character position 300 onwards...
And my file is having data only at 280 character position.
I want to add values from 300 character position onwards.
Well, you can first add 20 spaces at the end of each line (assuming that all the lines are of fixed length of 280 chars each) and then use your sed command to add the text at the end of the line. That would work I guess.
while read -r line
do
case "${#line}" in
[012][0-9][0-9] | [0-9][0-9] | [0-9] ) echo "${line}new characters...";;
* )echo "${line}";;
esac
done <"file"
Function : sed "s/.\{300\}/100200/g" cannot be parsed.
Is it anyway related to the fact that I want to append data at character position 300 when my file is having data at character position lesser than 300.
I mean last character in every line in my file is @ character position less than 300 and I am appending new data @ char position 300 onwards...