Insert text using sed

sed 's/$/TEST/g' will insert TEST at the end of each line. i want to insert TEST at column 64

How does your file look like..? Does it have any de-limiters..? If its of complex structure you would need to resort to awk.

this is a test,this is a test,this is a test,,,,,,,,,,,,,,,,,,this is a test,,,,,this is a test,,,,,

Hi,

Try with awk,

awk '{$64="LAST";}1' file - This will replace all the info in 64th field
awk '{$64=$64"LAST";}1' file - This will append end of 64th field
awk '{$64="LAST"$64;}1' file - This will append beginning of 64th field

Here I am assuming that field seperator is space.
You can specify any field seperator using FS in awk.

awk 'BEGIN{FS=",";}{$64="LAST"$64;}1' file 

Cheers
Ranga:)

sed 's/[^,]*/TEST/64' file
1 Like

after i executed sed, this is the output, and that is wrong:

this is a test,this is a test,this is a test,TEST,,,,,,,,,,,,,,,,,this is a test,,,,,this is a test,,,,,

it should look like this:
this is a test,this is a test,this is a test,,,,,,,,,,,,,,,,,,tTESThis is a test,,,,,this is a test,,,,,

Your input only has 36 columns. Do you mean character position 64?

sed 's/./TEST/64' file

you are correct SIR. i meant position. i am good for now. thank you very much.