Let's say I have a file named 'newfile' . Now I do some text substitution using sed command
sed 's/text1/text2/' newfile > newfile
In the above command I am subsituting text1 with text2 and then redirecting the output to the samefile. However after executing this command when I use
cat newfile
An empty file is showed.
What's the problem here?
sed -i 's/text1/text2/' newfile
so you don't clobber the file before it is processed. – doneal24 May 01 '18 at 12:14