batch append string to the end of a determined line in text files
I have text files of several thousand rows and I need to append a string (.php) at the end of the first line of all of them
I've managed to understand the sed program to the point of writing a working command for stdout:
sed -e '1,1s/$/.php/1'
It works great if I write the output files to a different directory (made for the occasion):
for X in *.txt
sed -e '1/1s/$/.php/1' $X >> ~/appended/$X
If I write $X >> $X, the filenames of the current directory remain but their text is all gone.
How can I output the file with the same name to the same directory?