What is file$1.txt
in a command? Or is this a script, and $1
is the positional parameter? Even then, we're not quite sure what you're trying to do. As others have mentioned, I think you'll need the -i
flag to change the files in place, but it would also help to see what's in the files, and what exactly you're trying to do. Perhaps you meant file$i.txt
?
But I'm not sure exactly what you're trying to do, so maybe it's best to create backup files:
for i in {1..200}; do sed -i.backup "s/foo/bar$i/g" file$i.txt; done