saving files after sed processing
SED doesn't seem to have a way to save a file once
it has been processed by sed commands. The only examples I have seen involve piping the output of sed processing to a temporary file, deleting the old file and renaming the temporary file, giving it the same name as the old. Is there a way to perform file processing with sed and saving the changed file without going through the aforementioned intermediate steps? Can PERL be used to perform changes w/o the intermediate steps? Which is best? |
Yes perl has an ability of inplace editing if you need class notes for my old perl class, let me see if I can submit it here w/o violating laws.
|
Well the perl inplace editing is just a wrapper. In the background it will still do something similar to what is done with sed and then move. Anyway to do the inplace editing you can make the following script:
Code:
#!/usr/bin/perl -i To do the same with sed is not that much harder it would just be one line. Something like: sed -e 's/something/else/' file > file.bak && mv -f file.bak file It would probably depend on what you are planning to use it for, which one of the two might be easier. |
All times are GMT -5. The time now is 03:42 PM. |