Originally Posted by aevangelica
I was just wondering if sed can write directly back to the file it reads from. As it stands, if i want to change foo to bar i do:
sed "s|foo|bar|g" $file > temp$file
mv temp$file $file
but that just seems wasteful to me. Thoughts?
GNU sed version 4.0.9:
sed --help [drastically snipped]
edit files in place (makes backup if extension supplied)
sed -ibak "s|foo|bar|g" $file outputs the modified file and creates file.bak(the original). No extension, no backup.