Replacing a variable in a loop

input.txt

I want to make 3 seprate ouputs such that

toast1.txt

ICH.txt

ICH_SV.txt

I have tried "echo" and "sed 's/k/toast1/g' to replace k, but its not quite working. Please help me out :slight_smile:
Thanks!

Did you try as below..?

$ sed 's/k/toast1/' input.txt
data<-read.table("toast1_file.txt")
Hi, hello 
$ 

right, but how do it make it in a loop such that it can do it for

toast1, ICH, ICH_SV

this is the idea, but i can't put ${i} in sed...

Replace with the below sed in the loop and try..

sed 's/k/'$i'/g' inputfile
1 Like

i was missing ' ' sign. Thanks!