Using sed to replace a placeholder in a string from a file

This piece of code will replace 400 times the value of STRING_TO_SEARCH from the contents of the file sample.txt.
It will replace it with the actual counter value and output everything to output.txt.

for i in `seq 1 400`
do
        sed 's/STRING_TO_SEARCH/'$i'/' sample.txt >> output.txt
done

Social tagging: >

Leave a Reply