How to make alterations to a file using sed , saving changes and retaining filename ?
Something which has been gnawing at me. I want to run a sed operation on a file / list of files, save the changes whilst keeping the original file name.
I'd assume this would overwrite the original file.
I've tried adjusting the noclobber settings, but I still get a file of size zero bytes.
Would the best bet be to append to say file2 , then delete the original ( file1 ) and rename file2 as file1 ?
Basically I have a directory full of html files and I need to delete specific lines but to retain the original file names as the files are hyperlinked with each other
Perhaps it could be done in Perl, but I already have the working sed syntax .
At present this sed problem is the rate limiting step in the overall shell script completion.
ps : It is not homework !!! If only I was that young again ! :)
"man sed" - look particularly for -i
Use the -i switch with an extension
-i is inline
-i.bak (No space) will make a .bak
sed -i.bak -e 's/findthis/changetothis/' /home/yourdir/yourtestfile
|All times are GMT -5. The time now is 10:41 PM.|